QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#611918#7330. Territory GameUrdAC ✓237ms68648kbC++173.1kb2024-10-05 00:15:232024-10-05 00:15:24

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 22044kb

input:

4 3
1 2
2 3
3 4
1 4 1
1 4 2
1 4 3

output:

1
0
2

result:

ok 3 number(s): "1 0 2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 26036kb

input:

2 8
1 2
1 2 1
1 2 2
1 2 3
1 2 4
2 1 1
2 1 2
2 1 3
2 1 4

output:

2
0
2
0
2
0
2
0

result:

ok 8 numbers

Test #3:

score: 0
Accepted
time: 4ms
memory: 21996kb

input:

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

output:

2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
2
0
1
-1
1
-1
1
-1
2
0
2
0
2
0
1
-1
1
-1
1
-1

result:

ok 36 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 24084kb

input:

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

output:

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

result:

ok 192 numbers

Test #5:

score: 0
Accepted
time: 0ms
memory: 24004kb

input:

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

output:

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

result:

ok 600 numbers

Test #6:

score: 0
Accepted
time: 4ms
memory: 22100kb

input:

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

result:

ok 6468 numbers

Test #8:

score: 0
Accepted
time: 4ms
memory: 21984kb

input:

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

output:

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

result:

ok 25984 numbers

Test #9:

score: 0
Accepted
time: 10ms
memory: 24160kb

input:

9 1296
5 4
4 2
2 3
2 8
5 1
1 7
1 9
5 6
1 2 1
1 2 2
1 2 3
1 2 4
1 2 5
1 2 6
1 2 7
1 2 8
1 2 9
1 2 10
1 2 11
1 2 12
1 2 13
1 2 14
1 2 15
1 2 16
1 2 17
1 2 18
1 3 1
1 3 2
1 3 3
1 3 4
1 3 5
1 3 6
1 3 7
1 3 8
1 3 9
1 3 10
1 3 11
1 3 12
1 3 13
1 3 14
1 3 15
1 3 16
1 3 17
1 3 18
1 4 1
1 4 2
1 4 3
1 4 4
1 4...

output:

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

result:

ok 60912 numbers

Test #10:

score: 0
Accepted
time: 85ms
memory: 34596kb

input:

5000 5000
2064 4325
667 740
3177 394
2334 1488
2691 4373
401 3052
2406 2326
2532 3838
542 135
162 1340
3644 1935
2376 1026
3322 1573
3156 2500
4625 1315
59 952
2168 2756
263 607
4023 571
4630 197
1915 4527
2629 3365
1371 2517
1592 1134
1716 112
3822 986
4147 3298
3337 4593
4739 416
2721 4801
2662 45...

output:

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

result:

ok 200000 numbers

Test #11:

score: 0
Accepted
time: 76ms
memory: 30808kb

input:

5000 5000
4455 4458
1192 1180
4739 4748
241 258
3516 3526
2659 2660
3096 3101
4633 4624
4686 4677
4203 4195
2754 2758
1935 1936
2118 2122
2074 2072
4261 4257
2274 2270
2004 2017
3474 3479
4384 4381
610 608
3125 3132
1869 1862
4345 4349
2236 2233
2794 2802
4290 4291
338 337
4893 4897
817 827
1582 161...

output:

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

result:

ok 200000 numbers

Test #12:

score: 0
Accepted
time: 237ms
memory: 52256kb

input:

200000 200000
92730 181199
38837 182835
71312 108585
121481 98424
183932 119127
120539 155369
2127 151235
104887 121805
82050 2595
119129 2759
89663 129962
115544 198800
50651 114956
12187 129275
64082 120776
140999 14404
147807 70230
181718 86055
34952 4311
140250 2200
197157 191802
51357 123986
10...

output:

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

result:

ok 200000 numbers

Test #13:

score: 0
Accepted
time: 150ms
memory: 52264kb

input:

200000 200000
186204 169159
89116 86263
40883 48037
98340 103172
171991 172107
182256 185416
78988 79480
115828 116943
198265 196946
95775 94930
111689 103330
130493 133063
1472 1816
177860 182285
101084 100197
21242 24282
115855 119323
81061 79093
53111 43245
93597 80079
73467 67956
188540 195931
1...

output:

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

result:

ok 200000 numbers

Test #14:

score: 0
Accepted
time: 153ms
memory: 52604kb

input:

200000 200000
32111 32145
22582 22497
169745 169556
184886 183841
173772 173435
97857 98150
80637 81340
54274 54876
132013 132771
864 72
185645 185595
41190 41165
128186 128199
106132 106829
97304 97342
136071 136088
196699 196533
118059 117861
26758 27069
142601 142234
198168 198456
175480 175629
1...

output:

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

result:

ok 200000 numbers

Test #15:

score: 0
Accepted
time: 158ms
memory: 53648kb

input:

200000 200000
185586 185596
13361 13332
6195 6242
135359 135364
132597 132592
149835 149832
130613 130617
119157 119174
95116 95105
29289 29308
63123 63124
184901 184972
96469 96489
123113 123121
197521 197630
88723 88918
50261 50249
17243 17167
185636 185622
21850 21861
165058 165014
186796 186745
...

output:

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

result:

ok 200000 numbers

Test #16:

score: 0
Accepted
time: 149ms
memory: 68648kb

input:

200000 200000
92192 92196
167616 167617
58244 58245
112443 112441
45046 45045
64045 64046
38826 38827
89663 89662
57217 57215
189516 189518
19828 19827
23699 23700
127710 127707
91194 91195
109553 109555
115068 115069
74104 74105
131070 131071
150412 150411
64557 64560
96402 96400
137438 137437
3960...

output:

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

result:

ok 200000 numbers

Extra Test:

score: 0
Extra Test Passed