QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512252#5526. Jewel of Data Structure ProblemsHuangHanShengTL 173ms12160kbC++173.9kb2024-08-10 13:57:172024-08-10 13:57:17

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 10032kb

input:

5 6
2 1 3 4 5
1 2
1 2
1 4
2 1
3 5
1 3

output:

-1
5
4
5
3
5

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 99ms
memory: 11968kb

input:

2 200000
1 2
2 1
2 1
2 1
1 2
1 2
2 1
1 2
2 1
2 1
1 2
2 1
2 1
2 1
2 1
2 1
2 1
1 2
2 1
2 1
1 2
1 2
2 1
1 2
1 2
1 2
1 2
2 1
1 2
1 2
1 2
2 1
2 1
1 2
2 1
2 1
2 1
2 1
1 2
1 2
2 1
2 1
1 2
2 1
1 2
1 2
2 1
1 2
1 2
2 1
2 1
1 2
1 2
2 1
2 1
2 1
1 2
1 2
1 2
1 2
2 1
1 2
2 1
1 2
1 2
2 1
1 2
2 1
1 2
2 1
2 1
2 1
2 1...

output:

2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
2
-1
...

result:

ok 200000 numbers

Test #3:

score: 0
Accepted
time: 99ms
memory: 12088kb

input:

3 200000
2 1 3
2 1
1 3
2 3
2 3
1 3
2 1
2 1
1 3
1 2
3 1
3 1
2 1
1 2
2 1
2 3
2 1
1 3
1 2
1 2
2 3
1 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4
-1
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
2
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
3
4
...

result:

ok 200000 numbers

Test #5:

score: 0
Accepted
time: 137ms
memory: 12012kb

input:

5 200000
5 2 4 3 1
3 2
2 5
5 3
4 3
5 4
2 1
4 1
2 4
4 5
2 4
5 1
2 3
1 3
3 4
1 4
2 5
5 4
4 1
3 1
2 3
5 2
1 4
3 4
5 2
4 2
2 3
5 4
1 2
2 4
2 5
4 5
1 2
3 4
1 2
2 1
3 2
3 4
5 2
1 3
4 1
3 1
4 1
5 3
3 5
1 5
1 3
3 4
3 1
2 4
2 4
3 2
3 2
5 2
4 1
4 5
5 1
5 4
1 5
4 5
3 2
3 5
4 1
3 2
3 2
4 3
3 4
2 5
5 1
1 3
4 3
4...

output:

5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
3
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
3
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
3
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
3
5
4
5
4
5
4
5
-1
5
4
5
4
5
-1
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
4
5
3
5
4
5
...

result:

ok 200000 numbers

Test #6:

score: 0
Accepted
time: 134ms
memory: 9964kb

input:

6 200000
4 2 5 3 6 1
1 2
4 6
5 4
1 6
6 5
4 2
5 3
6 2
6 5
1 4
6 3
6 5
2 3
4 5
4 1
3 6
5 6
2 4
3 2
2 3
6 1
1 3
1 3
3 6
1 6
2 5
3 4
1 4
4 1
4 6
3 5
6 2
6 5
4 1
5 6
5 4
1 6
2 4
6 3
1 3
5 2
1 6
1 3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7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
7
6
...

result:

ok 200000 numbers

Test #8:

score: 0
Accepted
time: 162ms
memory: 12004kb

input:

8 200000
5 4 7 1 6 2 8 3
8 4
5 3
2 6
5 3
3 5
1 6
3 4
5 3
1 3
1 2
6 3
8 7
8 3
3 8
6 4
3 4
3 7
6 4
4 2
7 3
4 8
7 8
8 5
4 3
8 1
1 2
2 1
6 5
7 2
7 1
6 1
3 6
6 1
6 1
7 1
7 3
2 3
3 7
4 7
8 5
3 1
2 7
2 3
4 5
3 2
4 6
4 8
4 6
8 1
1 2
8 6
5 6
7 2
6 7
5 8
4 2
6 3
6 3
8 3
6 7
8 7
8 2
6 8
1 4
5 1
2 3
4 6
7 5
8 4...

output:

8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
8
7
...

result:

ok 200000 numbers

Test #9:

score: 0
Accepted
time: 171ms
memory: 9928kb

input:

9 200000
4 3 8 9 2 1 7 5 6
9 6
1 6
4 1
7 3
7 9
5 8
6 2
1 4
2 3
3 8
5 8
7 4
6 4
3 7
9 8
3 8
9 5
9 3
6 3
7 8
1 6
1 9
2 3
7 6
9 1
9 5
1 6
9 7
6 7
3 5
6 7
5 7
7 6
2 6
2 6
8 4
2 8
3 9
5 8
3 9
6 2
6 9
8 5
2 5
6 5
8 5
6 2
1 5
7 6
6 9
2 8
6 9
2 5
8 9
6 8
2 5
1 7
3 2
9 1
6 7
8 9
3 7
5 3
4 7
7 2
8 2
2 3
8 2
6...

output:

9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
9
8
...

result:

ok 200000 numbers

Test #10:

score: 0
Accepted
time: 173ms
memory: 10036kb

input:

10 200000
7 10 4 9 1 6 2 3 5 8
4 9
8 7
2 3
6 10
4 5
7 6
5 6
2 6
10 1
7 5
9 10
8 9
6 9
8 5
2 3
5 1
5 7
5 4
1 9
7 4
2 7
8 6
3 10
1 2
4 1
1 5
5 8
5 7
10 3
2 7
1 5
8 10
10 6
8 10
10 4
1 10
5 4
5 10
2 10
6 5
8 6
8 1
8 9
2 4
4 2
10 9
9 8
2 8
4 1
7 10
9 7
10 9
7 3
2 6
4 8
5 9
6 9
1 2
1 5
10 6
1 2
5 10
10 7...

output:

10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
10
9
...

result:

ok 200000 numbers

Test #11:

score: -100
Time Limit Exceeded

input:

1000 200000
82 684 685 362 991 147 175 795 885 927 938 576 958 210 494 72 823 989 662 585 461 853 955 282 310 348 861 735 249 988 994 923 513 153 496 598 776 273 965 587 833 157 244 722 30 102 935 571 432 488 211 624 121 302 867 57 588 106 901 393 394 626 363 70 887 331 870 83 708 891 46 275 193 702...

output:

1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
1000
999
100...

result: