QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344818#3059. Buffalo BarricadesMilmonAC ✓438ms35476kbC++141.6kb2024-03-05 14:24:342024-03-05 14:24:35

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
1
3
2

result:

ok 4 lines

Test #2:

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

input:

10
64 37
51 67
97 74
45 85
1 23
87 85
67 58
67 25
36 19
34 11
10
88 5
3 27
95 88
63 56
28 61
93 89
82 51
96 24
49 26
22 52

output:

0
1
8
2
0
0
2
0
2
0

result:

ok 10 lines

Test #3:

score: 0
Accepted
time: 2ms
memory: 12092kb

input:

900
5029 361
3803 9216
237 5194
9957 937
2738 7305
6543 6871
7355 4400
5526 7160
4945 3009
1765 3846
7840 3082
9780 5016
6026 4387
8260 2089
7974 90
7316 9354
451 1119
4921 7039
6312 1229
7975 5401
8533 4518
8623 5887
5269 4148
9399 6566
7156 1163
6763 1347
597 6542
2714 6622
7280 973
8710 1605
7415...

output:

8
185
345
54
45
2
2
5
24
14
0
33
7
5
121
12
4
4
7
33
25
1
8
13
13
6
70
2
68
2
8
23
35
10
0
1
2
2
1
0
0
3
2
8
0
7
25
2
1
1
10
14
6
23
1
4
13
0
1
0
1
2
24
41
2
7
12
6
32
11
2
6
0
34
0
2
1
2
0
5
0
8
1
0
5
0
0
0
0
15
1
6
9
2
3
0
11
1
3
15
3
0
0
1
0
37
44
0
0
1
0
0
0
11
3
1
8
2
19
0
2
0
13
0
6
5
2
0
7
7
...

result:

ok 1000 lines

Test #4:

score: 0
Accepted
time: 6ms
memory: 12124kb

input:

30000
154617 358190
969920 171311
790814 429690
89355 649753
442368 271204
60616 431884
510477 256960
159511 155485
520908 213115
484807 932304
470644 434803
620533 717052
13985 236182
449546 808653
452658 725252
379440 123627
83441 349359
294937 390606
295400 384292
40359 737767
171847 100974
16965...

output:

1430
13897
1541
369
3472
10516
73
5205
2812
565
1432
666
503
4002
96
424
848
694
88
224
929
48
118
43
576
116
43
285
137
154
158
1627
178
340
955
1220
2
121
5
31
469
347
50
124
599
26
346
3
111
170
386
7
167
16
1209
55
43
0
80
57
32
57
11
11
0
363
537
184
779
198
40
136
218
10
80
0
78
0
245
451
228
...

result:

ok 10000 lines

Test #5:

score: 0
Accepted
time: 265ms
memory: 20452kb

input:

290000
717671719 278332807
993676424 306880299
689750274 48112672
110955934 517289545
975767840 971258772
638293491 769857435
658579174 843203114
292289080 20706019
261920626 565699908
281395889 136167636
376998346 567544956
746820500 500595235
420288210 944489322
297519453 26062002
186972379 706335...

output:

45134
81807
16052
18544
1019
15326
9186
16110
4872
765
2188
9864
68
8564
2741
5264
3908
38429
50870
2955
15808
2791
1474
2062
319
23
2961
380
653
423
1136
2465
3470
1319
3010
542
506
7243
831
15976
13659
295
227
306
1066
497
7551
767
1953
45
4098
42
395
144
796
33
9324
214
2388
4551
514
2544
1250
85...

result:

ok 300000 lines

Test #6:

score: 0
Accepted
time: 260ms
memory: 20396kb

input:

300000
188048175 13532874
806502853 924292150
117535509 124381153
656441702 821812973
75661440 443598673
172787747 335531146
514544523 693791958
522116355 407248744
700448986 104195560
378545760 786462637
452268685 419442806
158830593 693685529
694396288 568939359
636163676 369774928
586760406 87629...

output:

52186
10748
199018
87352
23507
8089
26480
1916
3034
3511
9871
6081
42078
34010
10605
4416
9466
5776
996
1067
1888
211
79
830
9047
172
8731
15444
649
1587
5189
831
5017
2910
79
3059
5767
4925
2012
2404
4003
1900
551
101
2297
2897
2074
2747
537
329
10429
3080
3274
507
1347
1171
457
1108
247
2781
13
78...

result:

ok 300000 lines

Test #7:

score: 0
Accepted
time: 266ms
memory: 33084kb

input:

300000
506309624 701134596
272930802 671405893
166639949 17907574
604094476 740686526
789810181 27751430
816047851 184626509
940150522 775721597
87020895 641438663
773136531 718270479
560521330 249470665
907917564 297905476
354901712 652264099
196424384 739930350
33506625 591235943
411474271 5284113...

output:

7871
3485
293
3745
10102
2864
3241
762
109
2123
8811
7916
1939
47
1217
1133
412
1741
452
5780
577
734
2912
234
3000
7100
511
1158
26
1843
1151
3829
4605
165
1570
92
1
377
125
146
147
1036
4470
235
712
512
1511
1236
754
1045
759
36
19
932
89
737
98
0
863
1643
60
2561
74
1066
1307
342
95
0
404
471
25
...

result:

ok 300000 lines

Test #8:

score: 0
Accepted
time: 280ms
memory: 35476kb

input:

300000
687328154 207620275
612673277 159765002
187731793 324068376
328543837 308332096
218545633 40575550
100188355 434733650
58052192 50738987
360571630 369754780
118782362 389360920
703426855 945253618
297581830 91270197
226236581 632339298
499364808 754352214
107297387 91927963
451590326 89579707...

output:

15876
419
6361
481
1447
624
16711
2633
3730
7535
43
843
329
962
1203
6
191
211
225
141
949
268
814
259
325
844
294
8560
74
478
2466
1490
965
876
520
86
2273
1197
551
3014
10
1874
7
161
366
282
62
67
2563
328
166
217
134
24
8
47
1776
961
683
2881
514
2505
83
823
7729
1385
600
245
215
33
9
64
11
71
22...

result:

ok 300000 lines

Test #9:

score: 0
Accepted
time: 269ms
memory: 33544kb

input:

300000
131109069 101524623
556702127 817484115
62099615 78324160
40289437 349211126
645712131 727488878
878215215 402396246
128152267 214909842
529344477 676550703
783604619 162633474
210385424 582204489
654604612 138904442
593185758 270862541
158909388 706817670
641503491 602537187
42546361 8020443...

output:

7970
448
7535
1317
5397
14718
700
1746
2726
840
4040
78
145
356
406
101
220
17
2711
416
650
18
3
2360
843
9837
685
7
1671
5662
469
11
2470
1506
10
255
3140
135
518
646
245
792
4
106
561
381
8973
2047
711
1401
239
607
71
122
395
21
5146
289
1685
111
126
999
1279
20
113
280
825
3
541
294
4
26
127
319
...

result:

ok 300000 lines

Test #10:

score: 0
Accepted
time: 165ms
memory: 20300kb

input:

300000
63996590 154817261
200376739 195803529
341627327 529242878
617214159 259980775
668264240 946359106
339248954 838354892
921073747 3078464
163701634 628688374
149500496 469281698
979322614 936089617
621455585 800224143
98887039 592833641
987342523 9357638
747585924 368169834
141116214 100616220...

output:

6411
248
3676
1717
2653
1998
18044
22813
1354
13
52
1044
1285
10
168
892
3383
606
113
159
6798
1111
391
4353
1082
16
6939
3048
48
1075
1679
763
922
3645
238
326
3
157
1134
100
205
447
415
38
435
190
6851
6
6337
0
526
4
460
420
100
845
171
26
1403
306
131
291
811
2377
281
528
4221
147
94
446
713
86
1...

result:

ok 300000 lines

Test #11:

score: 0
Accepted
time: 438ms
memory: 33320kb

input:

300000
717584485 696521716
317578260 896307109
117188019 225015265
224809370 480742224
507117805 694079305
638631704 982921961
948903360 489594495
291036034 702768177
3957593 664072392
20835449 930247784
133472675 103468855
606913415 881131170
427581555 826404659
766199909 501071825
633629413 748747...

output:

38782
4071
9596
2505
1728
2194
1513
184
571
23720
18464
2278
1542
130
6783
56
199
1948
315
585
79
242
795
5
65
747
1716
863
691
1701
17
652
249
2778
1907
131
47
197
2478
315
725
375
45
2534
521
429
7
2132
238
175
873
944
180
5223
167
550
46
368
5178
250
822
59
367
22
742
144
4
1672
74
8
75
20
8
346
...

result:

ok 300000 lines

Test #12:

score: 0
Accepted
time: 177ms
memory: 20224kb

input:

300000
926422474 42510255
245906439 653956060
105111685 102293963
30422572 312635005
223308721 554601566
34613509 756441764
491616639 86897624
398827521 549161558
98738123 407779206
101762911 572535854
625350451 797864122
343715473 134943725
81665746 857393640
28465358 640583635
130486873 928863891
...

output:

21591
2316
14870
668
7406
3295
697
5904
248
696
656
302
7588
177
1419
432
3153
91
784
22
3653
47
267
99
660
1617
1349
0
240
1788
13
227
358
1
638
2804
558
1300
195
1
177
7369
1030
412
930
528
215
3526
180
826
1198
2917
375
137
5593
561
172
19
473
755
3
107
50
799
578
56
338
841
51
73
149
82
2978
232...

result:

ok 300000 lines

Test #13:

score: 0
Accepted
time: 177ms
memory: 20240kb

input:

300000
481787796 310323478
815517754 690210109
178153094 167858605
124492846 151966921
394527341 688066318
788125440 162601913
50529899 328313530
91375671 34396817
47809823 3813432
348888999 611416302
810509423 49807416
187859446 120195591
65161572 398474843
814766987 237488889
905776711 172839694
2...

output:

23711
12048
1957
5725
12556
838
319
4885
3209
403
1999
1556
464
2488
1207
6340
16795
33
645
1114
1865
44
936
61
718
264
3832
527
2742
51
533
268
2
249
274
173
4346
2335
1225
163
302
66
349
9
106
404
1502
32
233
494
3
377
306
164
345
2648
62
1296
2240
1787
86
275
195
76
256
560
11
27
881
9
2675
130
1...

result:

ok 300000 lines

Test #14:

score: 0
Accepted
time: 429ms
memory: 33384kb

input:

300000
482389460 60591329
29437102 691621896
623965483 250512453
496914109 374530858
204623157 811619952
257148885 683923662
488684032 942524289
745491733 329861155
471289706 157590683
729276341 781678600
496159229 561082356
64618360 748347342
696968056 381553928
348035066 705819382
760235957 286934...

output:

15940
639
11085
5691
995
15020
455
967
4462
1302
1639
1882
4338
540
460
988
5573
2016
156
501
306
296
2611
404
11
4940
92
950
4404
408
93
82
493
5127
14
88
3291
1113
221
1062
150
1088
159
117
1273
28
132
643
339
19
2184
26
1878
46
67
185
56
10
3
59
1425
2780
1956
65
354
4762
2524
81
83
55
251
73
37
...

result:

ok 300000 lines

Test #15:

score: 0
Accepted
time: 268ms
memory: 27088kb

input:

300000
500221321 739430180
513203357 899929672
275754328 364231366
617665482 716782735
482977787 81854194
262116335 208773135
258185642 36192430
856831010 582511388
711709151 344792816
612300521 123011430
133082226 146785294
146070403 138413223
475391237 280193329
725236098 952167378
77102478 346115...

output:

32186
809
6751
1396
5205
659
2486
13
850
6396
0
3385
1343
5054
1107
0
9
79
8331
1463
780
644
2915
4461
163
2561
303
22
1123
8665
1170
719
1815
788
56
136
1376
74
211
6629
78
146
3198
2214
4027
1019
3693
208
1900
170
297
336
389
584
1165
271
2289
31
895
391
1098
211
470
84
298
5
748
723
1
3718
200
11...

result:

ok 300000 lines

Test #16:

score: 0
Accepted
time: 227ms
memory: 27040kb

input:

300000
45374294 39489390
440417134 865822314
849315842 322632991
178442256 210143301
977022435 390975624
458579588 337957665
537733478 441526765
999960230 24509820
97301859 961187225
86194712 437225677
139852026 143052357
605116900 399433219
71177046 889782439
555606876 140624027
40031291 632872917
...

output:

29621
18622
659
1885
1451
330
4822
1278
1198
82
7877
88
6852
2345
16532
26
589
359
298
2140
3752
2
2358
3478
1640
1079
26
917
166
566
4877
5301
92
671
3845
562
4898
34
341
71
3508
52
200
140
9
148
278
1290
1876
246
2046
1234
644
148
428
1923
83
447
1406
1351
77
3242
133
1734
527
514
11
20
1303
39
61...

result:

ok 300000 lines

Test #17:

score: 0
Accepted
time: 226ms
memory: 27728kb

input:

300000
590594739 213976799
429431225 303177174
867905055 191262237
882198538 282688429
231933300 699023729
932103011 694579702
757963886 948235919
556190953 535297290
456262540 115909780
884235727 588041782
94727599 18940798
949297294 120324287
214075777 667660621
386451072 795780586
760065251 89470...

output:

3036
4267
446
691
4859
9721
11160
1075
26221
3907
747
22
7259
350
1153
393
351
162
42
361
391
620
11425
520
392
829
170
203
922
4409
68
82
4895
12
233
58
114
416
24
1711
1939
588
145
248
146
506
249
137
1666
2640
4384
1916
999
148
64
47
46
807
70
197
1212
490
440
9
1858
5996
515
20
219
27
3699
146
2...

result:

ok 300000 lines

Test #18:

score: 0
Accepted
time: 248ms
memory: 20484kb

input:

300000
698131 659741
769850 808078
413972 190724
680552 399996
549335 524110
316255 33018
598788 593105
272875 571612
597060 827849
198623 970490
142459 919453
135250 447578
136030 270147
299561 28994
645099 298747
676471 343229
958487 446321
151307 888810
153396 348210
288806 219082
872319 605060
2...

output:

32742
64122
38503
15297
12838
46710
6191
866
1815
119
18615
4135
22400
3863
22303
7083
508
6452
21101
2313
1670
6404
7364
194
854
5806
6516
7500
122
7
1869
60
8069
1421
488
1445
218
3047
10788
3672
10637
3459
788
2376
5426
10594
3236
3292
8817
11
154
4306
396
21
511
138
672
1064
35087
704
1810
43
18...

result:

ok 300000 lines

Test #19:

score: 0
Accepted
time: 233ms
memory: 25120kb

input:

300000
378958138 207731846
513209405 702925952
229202314 743910882
327608764 443976068
776657989 953757767
979288928 183549744
321098301 914230252
398547769 709471132
55887234 312451917
938497922 343741032
12427296 327006486
49874705 697354157
480942118 262910730
55694694 547354614
679592466 9277723...

output:

17851
1
1
1
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
2
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
2
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
2
1
3
1
1
0
1
0
0
0
0
0
1
0
2
0
2
1
1
0
2
0
0
2
0
0
0
0
2
2
1
0
2
3
0
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
1
0
0
3
0
1
0
2
0
0
0
1
0
0
0
3
1
0
...

result:

ok 300000 lines

Test #20:

score: 0
Accepted
time: 292ms
memory: 27196kb

input:

300000
571101456 151842647
48190368 883978220
307124675 512436707
998282456 616375338
375760345 370729818
853253270 415270035
95441654 593269344
481125040 502661749
912131660 195604843
27655718 556332125
911811845 655269340
643943878 127741579
864092369 442545908
4217 268784223
66281403 106123506
99...

output:

1025
658
1120
421
286
15
155
70
588
145
3
190
1090
77
44
193
66
2
180
155
29
14
117
32
1
74
44
214
76
17
30
3
184
29
0
8
153
239
0
52
10
14
0
64
1
199
217
18
0
26
36
310
1
113
18
273
3
47
27
18
1
60
10
64
8
23
31
14
37
18
281
12
150
0
39
18
1
92
51
1
181
41
8
78
122
13
7
8
25
13
0
46
3
13
243
26
10
...

result:

ok 300000 lines

Test #21:

score: 0
Accepted
time: 279ms
memory: 31984kb

input:

300000
265514625 593945236
952302623 321405195
131179760 851060719
347965115 110738798
539897235 879387266
168693802 346011758
10613 237274394
696510945 712269488
419621999 800373096
640578268 728765997
523155442 314861471
622176657 240361842
630007341 417508510
504911302 541413425
497548866 8606308...

output:

550
14
1680
245
2631
265
82
148
0
190
16
226
709
56
74
22
11
149
38
87
21
336
300
64
1
35
11
25
223
1056
83
102
207
325
81
28
115
27
139
3
7
43
0
10
71
3
97
72
45
168
4
89
30
10
3
46
14
18
0
50
155
15
36
0
88
33
2
7
12
1
57
203
0
13
1
26
60
110
45
8
94
20
22
194
407
190
23
0
10
10
3
52
8
7
127
120
2...

result:

ok 300000 lines