100242024-03-24 14:39:12111Széfnyitáscpp17Wrong answer 0/1003ms4188 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
#ifdef DEBUG
start:
	N=2+rand()%99;
	// N=4;
#else
	cin>>N;
#endif
	int a[N+1],g[N+1][2];
	for(int i=1;i<=N;i++){
#ifdef DEBUG
		a[i]=rand()&1,g[i][0]=1+rand()%N,g[i][1]=1+rand()%N;
#else
		cin>>a[i]>>g[i][0]>>g[i][1];
#endif
	}
	int K;
#ifdef DEBUG
	K=N;
#else
	cin>>K;
#endif
	for(int t=0;t<10;t++){
		vector<int>b(N);
		for(int i=0;i<N;i++){
			b[i]=rand()&1;
		}
		map<vector<int>,vector<int>>m;
		int ok=1;
		for(int z=1;z<=N;z++){
			vector<int>v(N),c;
			int x=z;
			for(int i=0;i<N;i++){
				v[i]=a[x];
				x=g[x][b[i]];
			}
			vector<int>w(N+1);
			for(int i=0;i<N*2;i++){
				if(w[x]==1){
					c.push_back(a[x]);
				}
				w[x]++;
				x=g[x][a[x]];
			}
			if(m.count(v)&&m[v]!=c&&count(c.begin(),c.end(),0)&&count(c.begin(),c.end(),1)){
				// for(int i:v)cout<<i<<' ';cout<<endl;
				// for(int i:c)cout<<i<<' ';cout<<endl;
				// for(int i:m[v])cout<<i<<' ';cout<<endl;
				ok=0;
				break;
			}
			m[v]=c;
		}
		if(ok){
#ifdef DEBUG
			// cout<<"ok"<<endl;
			goto start;
#endif
			return 0;
		}
	}
#ifdef DEBUG
	cout<<N<<endl;
	for(int i=1;i<=N;i++){
		cout<<a[i]<<' '<<g[i][0]<<' '<<g[i][1]<<endl;
	}
#endif
	return 1;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1824 KiB
2Wrong answer3ms2028 KiB
subtask20/16
3Wrong answer3ms2232 KiB
4Wrong answer2ms2312 KiB
5Wrong answer3ms2448 KiB
6Wrong answer2ms2520 KiB
7Wrong answer3ms2652 KiB
8Wrong answer3ms2872 KiB
9Wrong answer3ms2972 KiB
10Wrong answer3ms3092 KiB
11Wrong answer3ms3328 KiB
12Wrong answer2ms3380 KiB
13Wrong answer3ms3524 KiB
subtask30/24
14Wrong answer3ms3740 KiB
15Wrong answer3ms3732 KiB
16Wrong answer3ms3732 KiB
17Wrong answer2ms3732 KiB
18Wrong answer2ms3736 KiB
19Wrong answer3ms3736 KiB
20Wrong answer3ms3612 KiB
21Wrong answer3ms3608 KiB
subtask40/23
22Wrong answer3ms3632 KiB
23Wrong answer3ms3708 KiB
24Wrong answer3ms3712 KiB
25Wrong answer3ms3708 KiB
26Wrong answer3ms3856 KiB
27Wrong answer3ms3712 KiB
28Wrong answer3ms3708 KiB
29Wrong answer2ms3708 KiB
subtask50/37
30Wrong answer3ms2232 KiB
31Wrong answer2ms2312 KiB
32Wrong answer3ms2448 KiB
33Wrong answer2ms2520 KiB
34Wrong answer3ms2652 KiB
35Wrong answer3ms2872 KiB
36Wrong answer3ms2972 KiB
37Wrong answer3ms3092 KiB
38Wrong answer3ms3328 KiB
39Wrong answer2ms3380 KiB
40Wrong answer3ms3524 KiB
41Wrong answer3ms3740 KiB
42Wrong answer3ms3732 KiB
43Wrong answer3ms3732 KiB
44Wrong answer2ms3732 KiB
45Wrong answer2ms3736 KiB
46Wrong answer3ms3736 KiB
47Wrong answer3ms3612 KiB
48Wrong answer3ms3608 KiB
49Wrong answer3ms3632 KiB
50Wrong answer3ms3708 KiB
51Wrong answer3ms3712 KiB
52Wrong answer3ms3708 KiB
53Wrong answer3ms3856 KiB
54Wrong answer3ms3712 KiB
55Wrong answer3ms3708 KiB
56Wrong answer2ms3708 KiB
57Wrong answer3ms3732 KiB
58Wrong answer3ms3948 KiB
59Wrong answer3ms3956 KiB
60Wrong answer3ms4060 KiB
61Wrong answer3ms4100 KiB
62Wrong answer3ms4108 KiB
63Wrong answer3ms4188 KiB
64Wrong answer3ms4168 KiB
65Wrong answer3ms4152 KiB
66Wrong answer3ms4172 KiB
67Wrong answer3ms4184 KiB
68Wrong answer3ms4156 KiB