QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667278#7158. Carnival Generalpackmani100 ✓20ms11268kbC++141.4kb2024-10-22 22:01:382024-10-22 22:01:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-22 22:01:46]
  • 评测
  • 测评结果:100
  • 用时:20ms
  • 内存:11268kb
  • [2024-10-22 22:01:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int SZ = 1005;
int n;
int adj[SZ];
int nono[SZ][SZ];
int cur,temp,num,lastnono,lastcur;
int s,l;
int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> n;
	//cout << n << '\n';
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<i;j++)
		{
			cin >> num;
			if(j>=(i+1)/2) 
			{
				nono[i][num]=1;
				//cout << i << j << ' ' << num << '\n';
			}
		}
	}
	//cout << "test";
	for(int i=1;i<n;i++)
	{
		/*
		l=s;
		cout << " | ";
		for(int k=0;k<n;k++)
		{
			cout << l << ' ';
			l=adj[l];
		}
		cout << '\n';
		*/
		cur=s; lastnono=0;
		//cout << cur << ' ';
		if(!nono[i][cur]) //check first
		{
			adj[i]=cur;
			s=i;
			continue;
		}
		else lastnono=1;
		lastcur=cur;
		cur=adj[cur];
		for(int j=1;j<i;j++) //check inside
		{
			//cout << cur << ' ';
			if(!nono[i][cur] and lastnono==0) 
			{
				//temp = adj[cur];
				adj[lastcur]=i;
				adj[i]=cur;
				break;
			}
			else if(!nono[i][cur])
			{	
				lastnono=0;
			}
			else
			{
				lastnono=1;
			}
			if(j!=i-1)
			{
				lastcur=cur;
				cur=adj[cur];
			}
			else//check last
			{
				if(!nono[i][cur])
				{
					adj[cur]=i;
					break;
				}
			}
			
		}
		
	}
	//cout << " | ";
	for(int k=0;k<n;k++)
		{
			cout << s << ' ';
			s=adj[s];
		}
		//cout << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 11
Accepted

Test #1:

score: 11
Accepted
time: 0ms
memory: 3628kb

input:

2
0

output:

1 0 

result:

ok correct

Test #2:

score: 11
Accepted
time: 0ms
memory: 4048kb

input:

99
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
11 10 9 8 7 6 5 4 3 2 1 0
12 11 10 9 8 7 6 5 4 3 2 1 0
13 12 11 10 9 8 7 6 5 4 3 2 1 0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 1...

output:

98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 

result:

ok correct

Test #3:

score: 11
Accepted
time: 18ms
memory: 11072kb

input:

1000
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
11 10 9 8 7 6 5 4 3 2 1 0
12 11 10 9 8 7 6 5 4 3 2 1 0
13 12 11 10 9 8 7 6 5 4 3 2 1 0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16...

output:

999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 ...

result:

ok correct

Test #4:

score: 11
Accepted
time: 1ms
memory: 5632kb

input:

8
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0

output:

7 6 5 4 3 2 1 0 

result:

ok correct

Test #5:

score: 11
Accepted
time: 0ms
memory: 3576kb

input:

6
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0

output:

5 4 3 2 1 0 

result:

ok correct

Subtask #2:

score: 23
Accepted

Test #6:

score: 23
Accepted
time: 0ms
memory: 3632kb

input:

2
0

output:

1 0 

result:

ok correct

Test #7:

score: 23
Accepted
time: 1ms
memory: 5720kb

input:

99
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 ...

output:

63 31 64 15 65 32 66 7 67 33 68 16 69 34 70 3 71 35 72 17 73 36 74 8 75 37 76 18 77 38 78 1 79 39 80 19 81 40 82 9 83 41 84 20 85 42 86 4 87 43 88 21 89 44 90 10 91 45 92 22 93 46 94 0 95 47 96 23 97 48 98 11 49 24 50 5 51 25 52 12 53 26 54 2 55 27 56 13 57 28 58 6 59 29 60 14 61 30 62 

result:

ok correct

Test #8:

score: 23
Accepted
time: 19ms
memory: 10848kb

input:

1000
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 ...

output:

511 255 512 127 513 256 514 63 515 257 516 128 517 258 518 31 519 259 520 129 521 260 522 64 523 261 524 130 525 262 526 15 527 263 528 131 529 264 530 65 531 265 532 132 533 266 534 32 535 267 536 133 537 268 538 66 539 269 540 134 541 270 542 7 543 271 544 135 545 272 546 67 547 273 548 136 549 27...

result:

ok correct

Test #9:

score: 23
Accepted
time: 19ms
memory: 10836kb

input:

999
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1...

output:

511 255 512 127 513 256 514 63 515 257 516 128 517 258 518 31 519 259 520 129 521 260 522 64 523 261 524 130 525 262 526 15 527 263 528 131 529 264 530 65 531 265 532 132 533 266 534 32 535 267 536 133 537 268 538 66 539 269 540 134 541 270 542 7 543 271 544 135 545 272 546 67 547 273 548 136 549 27...

result:

ok correct

Test #10:

score: 23
Accepted
time: 0ms
memory: 3640kb

input:

8
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6

output:

7 3 1 4 0 5 2 6 

result:

ok correct

Test #11:

score: 23
Accepted
time: 0ms
memory: 3648kb

input:

5
0
0 1
0 1 2
0 1 2 3

output:

3 1 4 0 2 

result:

ok correct

Subtask #3:

score: 29
Accepted

Test #12:

score: 29
Accepted
time: 0ms
memory: 3628kb

input:

2
0

output:

1 0 

result:

ok correct

Test #13:

score: 29
Accepted
time: 0ms
memory: 3580kb

input:

8
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0

output:

7 6 5 4 3 2 1 0 

result:

ok correct

Test #14:

score: 29
Accepted
time: 0ms
memory: 3632kb

input:

8
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6

output:

7 3 1 4 0 5 2 6 

result:

ok correct

Test #15:

score: 29
Accepted
time: 0ms
memory: 3720kb

input:

8
0
0 1
0 1 2
2 1 0 3
4 3 0 2 1
4 3 0 5 2 1
6 5 2 1 4 0 3

output:

7 5 3 1 0 2 4 6 

result:

ok correct

Test #16:

score: 29
Accepted
time: 0ms
memory: 3716kb

input:

8
0
1 0
0 1 2
3 2 1 0
0 1 2 3 4
5 4 3 2 1 0
0 1 2 3 4 5 6

output:

6 4 2 5 1 7 3 0 

result:

ok correct

Test #17:

score: 29
Accepted
time: 0ms
memory: 3580kb

input:

3
0
0 1

output:

1 0 2 

result:

ok correct

Test #18:

score: 29
Accepted
time: 0ms
memory: 3712kb

input:

5
0
1 0
0 2 1
1 3 2 0

output:

4 3 2 1 0 

result:

ok correct

Test #19:

score: 29
Accepted
time: 0ms
memory: 3568kb

input:

6
0
0 1
0 1 2
0 2 1 3
0 2 3 4 1

output:

5 3 1 0 4 2 

result:

ok correct

Test #20:

score: 29
Accepted
time: 0ms
memory: 3588kb

input:

7
0
1 0
2 0 1
2 0 1 3
0 1 4 2 3
3 2 4 0 5 1

output:

6 3 2 1 5 0 4 

result:

ok correct

Test #21:

score: 29
Accepted
time: 0ms
memory: 3596kb

input:

8
0
1 0
0 1 2
3 2 0 1
3 1 0 4 2
4 2 0 3 5 1
6 4 3 1 5 2 0

output:

7 6 4 2 1 5 3 0 

result:

ok correct

Test #22:

score: 29
Accepted
time: 0ms
memory: 3664kb

input:

8
0
0 1
2 1 0
3 0 2 1
4 0 3 1 2
4 0 2 5 3 1
4 5 1 2 0 6 3

output:

7 5 4 3 1 0 6 2 

result:

ok correct

Test #23:

score: 29
Accepted
time: 0ms
memory: 3584kb

input:

8
0
0 1
0 1 2
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0

output:

7 6 5 4 3 1 0 2 

result:

ok correct

Test #24:

score: 29
Accepted
time: 0ms
memory: 3696kb

input:

8
0
1 0
2 1 0
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6

output:

7 3 2 5 1 4 0 6 

result:

ok correct

Test #25:

score: 29
Accepted
time: 0ms
memory: 3576kb

input:

8
0
1 0
1 0 2
1 3 0 2
1 3 0 2 4
1 3 5 0 2 4
1 3 5 0 2 4 6

output:

2 1 4 3 6 5 7 0 

result:

ok correct

Test #26:

score: 29
Accepted
time: 0ms
memory: 3588kb

input:

6
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0

output:

5 4 3 2 1 0 

result:

ok correct

Test #27:

score: 29
Accepted
time: 1ms
memory: 5748kb

input:

5
0
0 1
0 1 2
0 1 2 3

output:

3 1 4 0 2 

result:

ok correct

Test #28:

score: 29
Accepted
time: 0ms
memory: 3580kb

input:

4
0
1 0
0 2 1

output:

3 2 1 0 

result:

ok correct

Subtask #4:

score: 37
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #29:

score: 37
Accepted
time: 0ms
memory: 3620kb

input:

2
0

output:

1 0 

result:

ok correct

Test #30:

score: 37
Accepted
time: 1ms
memory: 3972kb

input:

99
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
11 10 9 8 7 6 5 4 3 2 1 0
12 11 10 9 8 7 6 5 4 3 2 1 0
13 12 11 10 9 8 7 6 5 4 3 2 1 0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 1...

output:

98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 

result:

ok correct

Test #31:

score: 37
Accepted
time: 15ms
memory: 11268kb

input:

1000
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
11 10 9 8 7 6 5 4 3 2 1 0
12 11 10 9 8 7 6 5 4 3 2 1 0
13 12 11 10 9 8 7 6 5 4 3 2 1 0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16...

output:

999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 ...

result:

ok correct

Test #32:

score: 37
Accepted
time: 0ms
memory: 3652kb

input:

8
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0

output:

7 6 5 4 3 2 1 0 

result:

ok correct

Test #33:

score: 37
Accepted
time: 1ms
memory: 4036kb

input:

99
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 ...

output:

63 31 64 15 65 32 66 7 67 33 68 16 69 34 70 3 71 35 72 17 73 36 74 8 75 37 76 18 77 38 78 1 79 39 80 19 81 40 82 9 83 41 84 20 85 42 86 4 87 43 88 21 89 44 90 10 91 45 92 22 93 46 94 0 95 47 96 23 97 48 98 11 49 24 50 5 51 25 52 12 53 26 54 2 55 27 56 13 57 28 58 6 59 29 60 14 61 30 62 

result:

ok correct

Test #34:

score: 37
Accepted
time: 15ms
memory: 10988kb

input:

1000
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 ...

output:

511 255 512 127 513 256 514 63 515 257 516 128 517 258 518 31 519 259 520 129 521 260 522 64 523 261 524 130 525 262 526 15 527 263 528 131 529 264 530 65 531 265 532 132 533 266 534 32 535 267 536 133 537 268 538 66 539 269 540 134 541 270 542 7 543 271 544 135 545 272 546 67 547 273 548 136 549 27...

result:

ok correct

Test #35:

score: 37
Accepted
time: 19ms
memory: 10856kb

input:

999
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1...

output:

511 255 512 127 513 256 514 63 515 257 516 128 517 258 518 31 519 259 520 129 521 260 522 64 523 261 524 130 525 262 526 15 527 263 528 131 529 264 530 65 531 265 532 132 533 266 534 32 535 267 536 133 537 268 538 66 539 269 540 134 541 270 542 7 543 271 544 135 545 272 546 67 547 273 548 136 549 27...

result:

ok correct

Test #36:

score: 37
Accepted
time: 0ms
memory: 3692kb

input:

8
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6

output:

7 3 1 4 0 5 2 6 

result:

ok correct

Test #37:

score: 37
Accepted
time: 0ms
memory: 3592kb

input:

8
0
0 1
0 1 2
2 1 0 3
4 3 0 2 1
4 3 0 5 2 1
6 5 2 1 4 0 3

output:

7 5 3 1 0 2 4 6 

result:

ok correct

Test #38:

score: 37
Accepted
time: 0ms
memory: 3588kb

input:

8
0
1 0
0 1 2
3 2 1 0
0 1 2 3 4
5 4 3 2 1 0
0 1 2 3 4 5 6

output:

6 4 2 5 1 7 3 0 

result:

ok correct

Test #39:

score: 37
Accepted
time: 0ms
memory: 3612kb

input:

3
0
0 1

output:

1 0 2 

result:

ok correct

Test #40:

score: 37
Accepted
time: 0ms
memory: 3580kb

input:

5
0
1 0
0 2 1
1 3 2 0

output:

4 3 2 1 0 

result:

ok correct

Test #41:

score: 37
Accepted
time: 0ms
memory: 3712kb

input:

6
0
0 1
0 1 2
0 2 1 3
0 2 3 4 1

output:

5 3 1 0 4 2 

result:

ok correct

Test #42:

score: 37
Accepted
time: 0ms
memory: 3648kb

input:

7
0
1 0
2 0 1
2 0 1 3
0 1 4 2 3
3 2 4 0 5 1

output:

6 3 2 1 5 0 4 

result:

ok correct

Test #43:

score: 37
Accepted
time: 0ms
memory: 3588kb

input:

8
0
1 0
0 1 2
3 2 0 1
3 1 0 4 2
4 2 0 3 5 1
6 4 3 1 5 2 0

output:

7 6 4 2 1 5 3 0 

result:

ok correct

Test #44:

score: 37
Accepted
time: 0ms
memory: 3632kb

input:

8
0
0 1
2 1 0
3 0 2 1
4 0 3 1 2
4 0 2 5 3 1
4 5 1 2 0 6 3

output:

7 5 4 3 1 0 6 2 

result:

ok correct

Test #45:

score: 37
Accepted
time: 0ms
memory: 3652kb

input:

8
0
0 1
0 1 2
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0

output:

7 6 5 4 3 1 0 2 

result:

ok correct

Test #46:

score: 37
Accepted
time: 0ms
memory: 3660kb

input:

8
0
1 0
2 1 0
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6

output:

7 3 2 5 1 4 0 6 

result:

ok correct

Test #47:

score: 37
Accepted
time: 0ms
memory: 3652kb

input:

8
0
1 0
1 0 2
1 3 0 2
1 3 0 2 4
1 3 5 0 2 4
1 3 5 0 2 4 6

output:

2 1 4 3 6 5 7 0 

result:

ok correct

Test #48:

score: 37
Accepted
time: 19ms
memory: 10208kb

input:

1000
0
1 0
0 1 2
3 2 1 0
0 1 2 3 4
5 4 3 2 1 0
0 1 2 3 4 5 6
7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8
9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9 10
11 10 9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 ...

output:

998 996 994 992 990 988 986 984 982 980 978 976 974 972 970 968 966 964 962 960 958 956 954 952 950 948 946 944 942 940 938 936 934 932 930 928 926 924 922 920 918 916 914 912 910 908 906 904 902 900 898 896 894 892 890 888 886 884 882 880 878 876 874 872 870 868 866 864 862 860 858 856 854 852 850 ...

result:

ok correct

Test #49:

score: 37
Accepted
time: 20ms
memory: 10824kb

input:

1000
0
0 1
0 1 2
2 3 0 1
2 0 4 1 3
5 4 1 3 2 0
5 4 2 0 3 6 1
4 5 6 3 2 1 0 7
5 3 4 1 8 2 7 6 0
7 2 8 1 0 5 4 6 9 3
6 7 3 0 1 9 5 10 8 2 4
10 8 0 1 3 2 7 11 4 5 6 9
4 3 11 6 8 9 0 7 10 5 1 2 12
7 2 4 5 6 11 0 8 1 3 13 9 12 10
2 0 3 12 10 5 8 1 4 11 13 9 6 7 14
10 8 5 6 4 3 12 13 15 11 1 0 7 2 14 9
5 ...

output:

998 996 993 991 989 992 987 995 981 999 994 978 997 990 985 988 986 976 982 980 979 975 984 974 983 977 972 971 970 967 973 966 965 961 957 963 968 951 962 950 964 969 952 953 954 955 960 949 956 959 958 948 947 946 943 942 940 939 945 938 937 936 934 933 931 935 929 927 925 928 930 932 941 944 922 ...

result:

ok correct

Test #50:

score: 37
Accepted
time: 0ms
memory: 3628kb

input:

17
0
0 1
2 1 0
2 0 1 3
2 1 3 4 0
3 2 1 5 4 0
2 4 6 1 0 5 3
6 4 1 2 0 5 7 3
2 4 3 8 0 5 1 7 6
7 5 9 4 3 1 8 6 0 2
2 10 6 5 0 8 3 7 1 4 9
5 4 10 6 1 9 0 7 8 2 3 11
6 2 11 12 3 5 7 1 4 10 0 8 9
8 10 4 11 6 3 2 7 9 13 1 5 12 0
3 2 12 14 5 6 4 11 7 1 0 8 10 13 9
9 4 13 7 1 11 12 14 8 2 6 0 15 10 3 5

output:

16 13 11 15 14 10 12 5 3 6 7 1 0 9 4 8 2 

result:

ok correct

Test #51:

score: 37
Accepted
time: 1ms
memory: 6352kb

input:

171
0
0 1
1 2 0
2 0 1 3
1 4 2 3 0
5 3 0 1 4 2
6 1 5 4 2 3 0
3 1 5 4 7 2 0 6
8 4 1 6 2 7 5 0 3
3 0 9 8 4 5 6 7 1 2
8 5 2 7 1 9 10 6 0 3 4
7 9 8 2 11 1 10 5 6 3 4 0
4 11 2 8 3 1 7 5 0 9 6 10 12
0 3 13 7 8 6 12 4 2 1 5 10 11 9
6 12 5 9 7 1 14 2 10 8 0 11 3 4 13
2 3 8 9 12 14 7 13 0 10 4 5 6 15 1 11
0 3...

output:

170 168 166 165 164 163 161 160 167 159 169 158 154 153 147 155 157 146 156 137 162 148 134 149 139 143 131 145 138 144 152 136 129 150 126 135 133 122 128 141 151 140 142 127 114 130 113 121 124 119 116 109 120 108 112 123 115 132 106 125 118 105 117 111 102 101 107 100 104 99 95 103 93 92 91 87 85...

result:

ok correct

Test #52:

score: 37
Accepted
time: 0ms
memory: 8272kb

input:

412
0
0 1
2 1 0
0 2 3 1
4 0 2 3 1
3 1 2 5 4 0
4 1 0 5 2 6 3
1 4 3 6 2 0 7 5
7 2 0 5 1 6 8 3 4
6 7 4 0 9 8 3 5 2 1
0 9 2 4 10 3 1 5 8 6 7
0 2 9 1 10 5 7 6 8 4 3 11
2 7 12 4 5 11 1 0 6 8 9 3 10
8 13 10 4 2 12 7 9 6 5 1 3 11 0
4 2 8 14 1 6 5 12 0 3 7 13 10 11 9
10 7 8 11 15 12 9 14 4 3 1 0 6 13 2 5
4 1...

output:

408 407 402 401 405 399 410 411 409 395 403 394 406 393 392 398 400 396 390 388 387 384 383 397 404 386 389 385 381 391 379 375 380 382 372 377 376 370 378 373 369 368 374 367 366 364 371 362 360 365 363 358 356 351 349 357 353 361 359 352 355 348 345 343 347 341 340 346 342 344 354 338 336 339 332 ...

result:

ok correct

Test #53:

score: 37
Accepted
time: 16ms
memory: 11036kb

input:

997
0
1 0
2 0 1
0 3 1 2
3 4 1 2 0
1 2 3 5 4 0
4 0 5 2 3 6 1
3 5 2 7 0 6 1 4
0 2 4 5 3 1 8 6 7
5 2 4 9 1 3 8 6 0 7
1 2 0 5 3 4 9 7 8 10 6
1 10 11 0 8 7 4 5 9 6 3 2
2 6 10 8 7 4 9 0 5 3 12 11 1
7 10 1 13 9 4 2 5 12 0 8 11 3 6
3 10 7 4 13 12 6 2 9 8 14 11 5 0 1
2 7 6 15 3 11 0 14 12 4 9 10 13 1 8 5
7 1...

output:

994 989 988 987 996 992 983 982 986 984 991 979 975 981 974 990 985 973 995 977 993 976 980 972 968 967 978 966 971 970 958 956 961 952 965 969 951 959 962 953 945 944 964 957 942 955 960 954 949 941 948 940 946 938 934 950 939 930 943 937 963 935 936 929 928 927 931 926 933 925 924 923 932 922 921 ...

result:

ok correct

Test #54:

score: 37
Accepted
time: 20ms
memory: 11212kb

input:

999
0
1 0
0 1 2
3 2 0 1
2 3 4 1 0
1 4 3 0 2 5
5 3 2 1 6 0 4
2 6 3 5 0 4 1 7
4 7 2 3 6 8 5 0 1
6 8 1 0 4 7 3 9 2 5
10 2 8 7 1 3 6 5 4 9 0
5 11 10 3 8 0 2 7 9 6 1 4
8 3 11 4 10 2 7 0 9 5 12 6 1
3 6 7 1 9 10 5 13 11 2 12 8 0 4
1 7 4 3 2 11 8 12 13 0 14 5 6 9 10
3 14 0 13 11 6 2 9 8 1 4 10 7 5 12 15
6 9...

output:

995 993 991 988 994 996 992 984 997 989 998 983 981 976 987 990 974 979 985 966 980 963 972 986 973 970 968 982 967 969 962 978 977 971 975 965 960 958 961 957 959 956 954 952 951 953 950 964 949 948 947 946 944 942 939 938 943 937 955 936 941 940 935 934 945 933 928 926 929 925 923 930 931 922 927 ...

result:

ok correct

Test #55:

score: 37
Accepted
time: 20ms
memory: 11044kb

input:

1000
0
1 0
0 2 1
1 0 2 3
1 2 4 3 0
4 0 5 2 3 1
2 0 4 6 1 3 5
7 2 5 6 4 0 1 3
3 7 1 8 5 2 0 4 6
7 5 6 1 9 8 3 0 4 2
9 2 0 1 8 6 3 4 7 5 10
1 6 11 3 0 9 7 5 8 2 10 4
2 5 0 3 6 8 1 12 4 9 11 10 7
0 9 12 10 1 5 4 6 3 8 13 11 7 2
1 6 5 8 10 9 12 4 0 2 14 13 7 11 3
14 7 11 10 4 6 3 13 12 8 9 5 2 0 15 1
11...

output:

998 997 991 999 989 984 995 996 983 986 993 994 992 988 985 978 976 987 979 990 980 981 982 973 972 974 971 970 969 966 977 964 975 967 960 959 961 963 956 968 955 958 952 962 957 949 954 946 950 953 965 944 948 947 951 939 945 933 941 932 943 936 935 930 928 942 927 937 931 929 924 938 922 926 920 ...

result:

ok correct

Test #56:

score: 37
Accepted
time: 14ms
memory: 11156kb

input:

1000
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3 4 5
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10 11
0 1 2 3 4 5 6 7 8 9 10 11 12
0 1 2 3 4 5 6 7 8 9 10 11 12 13
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 ...

output:

999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926 925 ...

result:

ok correct

Test #57:

score: 37
Accepted
time: 15ms
memory: 11224kb

input:

1000
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0
5 4 3 2 1 0
6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
8 7 6 5 4 3 2 1 0
9 8 7 6 5 4 3 2 1 0
10 9 8 7 6 5 4 3 2 1 0
11 10 9 8 7 6 5 4 3 2 1 0
12 11 10 9 8 7 6 5 4 3 2 1 0
13 12 11 10 9 8 7 6 5 4 3 2 1 0
14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16...

output:

999 499 498 997 497 995 496 993 495 991 494 989 493 987 492 985 491 983 490 981 489 979 488 977 487 975 486 973 485 971 484 969 483 967 482 965 481 963 480 961 479 959 478 957 477 955 476 953 475 951 474 949 473 947 472 945 471 943 470 941 469 939 468 937 467 935 466 933 465 931 464 929 463 927 462 ...

result:

ok correct

Test #58:

score: 37
Accepted
time: 15ms
memory: 11120kb

input:

1000
0
1 0
1 0 2
1 3 0 2
1 3 0 2 4
1 3 5 0 2 4
1 3 5 0 2 4 6
1 3 5 7 0 2 4 6
1 3 5 7 0 2 4 6 8
1 3 5 7 9 0 2 4 6 8
1 3 5 7 9 0 2 4 6 8 10
1 3 5 7 9 11 0 2 4 6 8 10
1 3 5 7 9 11 0 2 4 6 8 10 12
1 3 5 7 9 11 13 0 2 4 6 8 10 12
1 3 5 7 9 11 13 0 2 4 6 8 10 12 14
1 3 5 7 9 11 13 15 0 2 4 6 8 10 12 14
1 ...

output:

2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 52 51 54 53 56 55 58 57 60 59 62 61 64 63 66 65 68 67 70 69 72 71 74 73 76 75 78 77 80 79 82 81 84 83 86 85 88 87 90 89 92 91 94 93 96 95 98 97 100 99 102 101 ...

result:

ok correct

Test #59:

score: 37
Accepted
time: 0ms
memory: 3584kb

input:

6
0
1 0
2 1 0
3 2 1 0
4 3 2 1 0

output:

5 4 3 2 1 0 

result:

ok correct

Test #60:

score: 37
Accepted
time: 0ms
memory: 3572kb

input:

5
0
0 1
0 1 2
0 1 2 3

output:

3 1 4 0 2 

result:

ok correct

Test #61:

score: 37
Accepted
time: 0ms
memory: 3564kb

input:

4
0
1 0
0 2 1

output:

3 2 1 0 

result:

ok correct

Extra Test:

score: 0
Extra Test Passed