QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667273#7158. Carnival Generalspycoderyt#100 ✓86ms3816kbC++14840b2024-10-22 22:00:032024-10-22 22:00:20

Judging History

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

  • [2024-10-22 22:00:20]
  • 评测
  • 测评结果:100
  • 用时:86ms
  • 内存:3816kb
  • [2024-10-22 22:00:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x;
    cin>>n;
    vector<int > v;
    v.push_back(0);
    for(int i = 1;i<n;i++) {
        set<int> tmp;
        for(int j = 0;j<i;j++) {
            cin>>x;
            if(j>(i-1)/2)tmp.insert(x);
        }
        // cerr << i << "\n";
        // for(auto e : tmp)cerr<<e<<" ";
        // cerr<<"\n";
        if(tmp.find(v[0]) == tmp.end()) v.insert(v.begin(),i);
        else if (tmp.find(v[v.size()-1]) == tmp.end()) v.push_back(i);
        else {
            for(int j = 1;j+1<v.size();j++) {
                if(tmp.find(v[j]) == tmp.end() && tmp.find(v[j+1]) == tmp.end()) {
                    v.insert(v.begin() + j + 1, i);
                    break;
                }
            }
        }
    }
    for(auto e : v)cout<<e<< " ";
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 11
Accepted

Test #1:

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

input:

2
0

output:

1 0 

result:

ok correct

Test #2:

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

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: 72ms
memory: 3744kb

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: 0ms
memory: 3592kb

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: 3768kb

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: 3560kb

input:

2
0

output:

1 0 

result:

ok correct

Test #7:

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

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 55 27 56 13 57 28 58 6 59 29 60 14 61 30 62 2 51 25 52 12 53 26 54 5 49 24 50 11 97 48 98 23 96 47 95 

result:

ok correct

Test #8:

score: 23
Accepted
time: 76ms
memory: 3592kb

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: 76ms
memory: 3584kb

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: 3716kb

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 6 2 5 

result:

ok correct

Test #11:

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

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: 3776kb

input:

2
0

output:

1 0 

result:

ok correct

Test #13:

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

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: 3460kb

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 6 2 5 

result:

ok correct

Test #15:

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

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: 3788kb

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 0 3 7 

result:

ok correct

Test #17:

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

input:

3
0
0 1

output:

1 0 2 

result:

ok correct

Test #18:

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

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: 3464kb

input:

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

output:

5 3 1 0 2 4 

result:

ok correct

Test #20:

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

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 0 4 5 

result:

ok correct

Test #21:

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

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 0 3 5 

result:

ok correct

Test #22:

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

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 2 6 

result:

ok correct

Test #23:

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

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: 3736kb

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 6 0 4 

result:

ok correct

Test #25:

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

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 6 5 7 0 3 4 

result:

ok correct

Test #26:

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

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: 0ms
memory: 3492kb

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: 3568kb

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: 3500kb

input:

2
0

output:

1 0 

result:

ok correct

Test #30:

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

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: 72ms
memory: 3512kb

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: 1ms
memory: 3572kb

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: 3536kb

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 55 27 56 13 57 28 58 6 59 29 60 14 61 30 62 2 51 25 52 12 53 26 54 5 49 24 50 11 97 48 98 23 96 47 95 

result:

ok correct

Test #34:

score: 37
Accepted
time: 76ms
memory: 3816kb

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: 76ms
memory: 3520kb

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: 3460kb

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 6 2 5 

result:

ok correct

Test #37:

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

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: 3492kb

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 0 3 7 

result:

ok correct

Test #39:

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

input:

3
0
0 1

output:

1 0 2 

result:

ok correct

Test #40:

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

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: 3568kb

input:

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

output:

5 3 1 0 2 4 

result:

ok correct

Test #42:

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

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 0 4 5 

result:

ok correct

Test #43:

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

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 0 3 5 

result:

ok correct

Test #44:

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

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 2 6 

result:

ok correct

Test #45:

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

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: 3520kb

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 6 0 4 

result:

ok correct

Test #47:

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

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 6 5 7 0 3 4 

result:

ok correct

Test #48:

score: 37
Accepted
time: 70ms
memory: 3480kb

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: 77ms
memory: 3588kb

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 999 997 981 978 976 984 975 974 972 971 970 967 966 965 961 957 983 964 969 951 962 950 956 949 960 948 947 946 943 942 940 939 938 937 936 934 933 931 929 927 925 928 930 932 941 944 922 920 919 917 912 908 906 902 899 913 896 901 916 903 895 915 921 892 909 898 891 904 ...

result:

ok correct

Test #50:

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

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 8 1 0 9 2 4 7 

result:

ok correct

Test #51:

score: 37
Accepted
time: 2ms
memory: 3776kb

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 159 169 158 154 153 147 146 156 137 162 148 134 139 143 131 152 151 138 144 136 129 150 126 135 133 122 130 114 113 121 142 124 119 140 116 109 120 108 106 125 118 105 102 101 100 104 99 95 93 92 91 87 123 85 84 86 79 78 67 97 96 90 80 66 72 83 63 69 61 59 76 77 57 62...

result:

ok correct

Test #52:

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

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 390 388 387 384 383 397 404 386 389 385 381 379 375 380 372 376 370 373 369 368 374 367 366 364 371 362 360 358 356 351 349 355 359 361 348 345 343 347 341 340 338 336 332 331 335 329 328 326 334 325 354 350 323 321 330 319 318 316 327 324 ...

result:

ok correct

Test #53:

score: 37
Accepted
time: 76ms
memory: 3816kb

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 983 982 991 979 975 981 974 990 985 973 995 972 980 968 993 967 966 958 956 961 952 965 951 954 960 955 945 944 963 942 941 940 938 934 950 939 930 929 928 927 933 926 925 924 923 922 921 920 947 919 916 913 912 917 918 915 911 910 909 903 902 901 900 914 908 898 905 897 893 899 892 ...

result:

ok correct

Test #54:

score: 37
Accepted
time: 73ms
memory: 3760kb

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 983 981 976 987 974 979 997 966 963 971 967 969 962 978 977 960 958 961 957 959 986 956 954 952 951 950 964 949 948 947 946 944 942 939 938 937 955 936 935 934 933 928 926 929 925 923 922 927 921 920 917 916 914 913 912 915 911 910 909 908 907 902 898 903 897 906 896 ...

result:

ok correct

Test #55:

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

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 983 978 976 990 979 980 973 972 971 970 969 966 977 964 975 968 960 959 961 963 956 955 962 952 957 949 946 950 953 965 944 948 947 951 939 933 941 932 942 935 930 928 927 929 924 938 922 937 920 919 940 918 917 916 915 913 909 914 907 906 905 904 903 900 908 899 892 890 897 ...

result:

ok correct

Test #56:

score: 37
Accepted
time: 72ms
memory: 3764kb

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: 76ms
memory: 3524kb

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: 86ms
memory: 3484kb

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 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 104 ...

result:

ok correct

Test #59:

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

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: 3792kb

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: 3736kb

input:

4
0
1 0
0 2 1

output:

3 2 1 0 

result:

ok correct

Extra Test:

score: 0
Extra Test Passed