QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#143286#1139. StationsJasonwei#5 106ms4100kbC++17897b2023-08-21 00:47:582024-07-04 01:50:51

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 70ms
memory: 3808kb

input:

0
10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
3 1000
0 1
1 2
998 1000
166 178
393 452
389 179
622 429
892 866
872 18
899 227
835 637
587 769
504 386
369 577
65 441
523 17
803 221
878 321
637 892
696 473
16 146
840 322
495 986
353 275
330 585
831 402
719 810
704 830
780 940
53 901
894 911
394 482
...

output:

10
0
7
2
6
3
8
9
5
4
1
3
0
2
1
998
0
995
192
115
363
517
924
922
43
52
942
842
69
713
413
76
883
244
449
847
675
817
326
763
310
752
468
590
518
269
213
687
706
756
597
937
336
163
532
653
979
106
953
121
266
625
229
162
920
348
813
179
652
395
401
655
107
41
974
343
10
548
170
985
30
89
71
191
388
...

input:

1
59784
0 1 1
1
574 618 2
842
843
0 1 1
1
848 310 2
151
152
2 1 1
1
1 0 1
0
0 1 1
1
742 153 2
674
675
1 0 2
2
3
0 3 1
3
474 416 2
525
526
9 2 2
0
2
223 888 2
195
196
934 400 2
65
66
732 49 2
112
113
285 437 2
714
715
0 1 1
1
69 52 2
76
77
2 1 2
0
1
0 1 1
1
647 63 2
568
569
1 0 1
0
37 862 2
570
571
0...

output:

1
842
1
152
1
0
1
674
3
3
526
2
195
66
112
714
1
77
1
1
568
0
571
1
2
307
1
0
0
348
24
861
1
9
93
0
405
27
8
3
9
168
579
998
18
767
895
475
80
80
2
43
150
1
2
2
1
614
2
2
0
0
726
194
467
6
242
0
0
351
450
234
131
0
216
272
2
1
991
1
1
470
2
87
2
11
81
570
9
9
9
2
1
2
1
170
217
473
2
383
394
312
0
80...

result:

ok 

Test #2:

score: 5
Accepted
time: 70ms
memory: 3804kb

input:

0
10
999 1000
235 825
647 906
541 62
613 565
578 619
248 881
769 526
994 607
456 840
66 498
55 390
563 846
932 717
568 140
443 49
369 210
721 37
431 796
632 398
861 25
724 153
403 851
688 315
803 191
213 469
339 674
166 517
236 859
67 199
867 510
804 372
820 443
628 483
835 200
692 488
295 42
5 140
...

output:

999
0
445
296
148
422
649
523
103
635
926
275
992
502
641
223
6
364
755
116
997
812
29
875
32
447
421
264
806
634
655
866
198
605
705
737
571
613
596
691
137
855
383
664
873
495
147
197
528
410
179
349
788
735
446
118
165
9
550
359
41
478
740
807
213
766
769
407
477
149
222
399
253
395
151
401
310
9...

input:

1
50048
628 989 2
301
302
350 634 2
473
474
148 818 2
390
391
415 596 2
514
515
595 172 2
944
945
761 292 2
595
596
647 323 2
709
710
149 591 2
389
390
405 617 2
601
602
583 70 2
773
774
198 365 2
77
78
243 226 2
295
296
885 984 2
121
122
187 954 2
636
637
33 977 2
790
791
928 76 2
885
886
887 947 2...

output:

301
474
391
515
945
595
710
390
602
774
77
296
121
637
791
885
42
448
655
125
587
358
338
653
48
490
417
44
157
859
778
114
214
911
166
275
486
380
138
775
334
69
477
430
317
201
213
887
682
416
16
146
83
544
976
333
419
443
220
69
778
863
967
753
625
875
195
873
845
835
64
224
405
708
757
2
992
434...

result:

ok 

Test #3:

score: 5
Accepted
time: 106ms
memory: 4100kb

input:

0
10
2 1000
1 0
2 1000
0 1
2 1000
0 1
2 1000
0 1
2 1000
0 1
2 1000
0 1
2 1000
0 1
2 1000
1 0
2 1000
1 0
2 1000
0 1

output:

2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1

input:

1
100000
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1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
1
1
3
3
1
3
3
3
2
1
1
2
0
3
1
2
2
1
0
3
1
0
1
3
3
1
2
2
1
3
1
3
3
1
3
3
1
2
0
3
3
1
1
1
2
3
3
3
3
3
1
0
3
0
0
3
1
2
0
2
3
3
1
2
3
0
3
3
3
3
2
1
1
2
3
3
1
0
3
3
3
2
3
...

result:

ok 

Test #6:

score: 5
Accepted
time: 68ms
memory: 3780kb

input:

0
10
1000 1000
387 293
176 887
976 264
923 398
736 598
406 187
658 331
596 105
514 857
33 784
81 15
194 397
768 286
406 42
586 521
503 384
663 326
451 514
658 489
849 120
531 769
428 756
81 283
14 519
359 542
807 685
707 278
738 700
865 839
728 657
166 155
980 440
364 448
879 37
833 524
358 421
458 ...

output:

1000
0
204
642
585
761
143
648
420
606
52
329
112
700
497
753
452
100
398
4
732
141
817
826
87
734
397
97
534
498
27
335
5
216
917
637
372
269
440
394
214
415
801
635
785
346
229
978
105
728
443
28
193
182
851
327
656
12
362
330
146
261
598
369
291
378
40
788
161
262
126
661
915
693
916
400
658
931
...

input:

1
50055
296 127 2
420
421
585 531 2
528
529
565 254 2
287
288
383 148 2
341
342
738 173 2
376
377
985 796 2
429
430
274 309 2
400
401
740 121 2
770
771
753 911 2
757
758
361 572 2
313
314
226 654 2
626
627
865 958 2
645
646
418 397 2
256
257
91 148 2
725
726
69 722 2
655
656
506 514 2
5
6
127 636 2
...

output:

421
529
287
341
376
430
400
771
758
313
627
645
257
725
656
5
689
423
181
873
185
367
459
606
483
708
319
502
846
516
743
158
514
581
119
715
463
160
326
689
364
391
363
953
230
283
676
10
890
231
427
78
604
861
846
453
871
7
326
122
746
426
528
898
257
328
897
460
384
771
764
929
309
74
817
839
833...

result:

ok 

Test #7:

score: 5
Accepted
time: 62ms
memory: 3804kb

input:

0
1
1000 1000
502 584
460 198
192 539
565 266
519 363
448 97
907 459
427 458
694 915
546 555
23 843
177 257
733 258
98 274
983 648
708 132
685 763
616 357
880 61
772 108
967 710
238 549
117 105
737 775
495 935
586 688
808 121
970 747
798 332
958 750
58 830
829 120
34 964
168 357
886 646
241 920
100 ...

output:

1000
0
820
674
536
576
486
142
709
262
166
558
802
650
15
553
316
604
885
403
552
362
846
306
7
278
702
400
354
391
78
128
503
204
830
220
538
738
442
996
330
96
799
5
759
384
805
133
872
247
562
882
537
746
113
289
174
329
974
980
596
603
784
678
620
858
152
789
6
909
569
577
754
942
937
593
156
84...

input:

1
50046
735 906 2
515
516
60 384 2
191
192
650 875 2
600
601
58 35 2
193
194
240 838 2
11
12
933 252 2
317
318
323 496 2
927
928
65 629 2
186
187
311 24 2
939
940
35 82 2
216
217
122 680 2
129
130
162 147 2
89
90
1 144 2
250
251
874 881 2
376
377
608 340 2
642
643
154 242 2
97
98
614 54 2
636
637
16...

output:

515
192
600
194
11
317
927
187
940
216
130
90
250
376
643
97
637
90
776
313
211
950
599
439
677
896
670
108
409
859
638
430
433
289
112
743
954
688
17
289
376
791
296
645
293
463
459
732
888
743
78
385
539
159
998
410
258
667
226
567
338
842
384
73
88
783
632
776
404
377
43
606
470
560
239
791
956
5...

result:

ok 

Test #8:

score: 5
Accepted
time: 2ms
memory: 3840kb

input:

0
10
4 1000
0 1
1 2
2 3
4 1000
0 1
1 3
3 2
4 1000
0 2
2 1
1 3
4 1000
0 2
2 3
3 1
4 1000
0 3
3 1
1 2
4 1000
0 3
3 2
2 1
4 1000
1 0
0 2
2 3
4 1000
1 0
0 3
3 2
4 1000
1 2
2 0
0 3
4 1000
1 3
3 0
0 2

output:

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

input:

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

output:

5
4
2
1
2
5
2
2
4
2
4
5
5
5
0
4
5
5
5
5
1
0
1
2
5
1
5
1
2
3
1
3
4
2
1
4
2
2
1
5
5
1
4
5
5
5
4
3
5
5
2
4
2
1
2
5
1
1
2
4
5
1
1
1
1
2
4
4
4
4
2
1
4
5
2
3
2
1
5
5
2
2
1
2
1
2
1
5
5
2
1
1
2
4
4
1
2
4
1
2
5
5
5
2
1
5
4
2
1
5
1
4
4
1
3
5
1
2
5
2
4
4
5
4
5
2
5
2
1
1
2
5
0
2
5
2
4
2
1
4
4
4
2
0
1
4
5
2
1
2
...

result:

ok 

Test #10:

score: 5
Accepted
time: 2ms
memory: 4096kb

input:

0
3
3 1000
0 1
1 2
3 1000
0 2
2 1
3 1000
1 0
0 2

output:

3
0
2
1
3
0
1
2
3
0
1
2

input:

1
18
2 0 2
0
1
2 1 2
0
1
1 2 1
2
1 0 1
2
2 1 2
0
1
2 0 2
0
1
1 0 1
2
2 1 1
0
1 0 1
0
0 2 2
1
2
1 2 1
0
0 1 1
2
2 0 1
0
0 2 1
2
0 2 1
2
0 1 1
2
0 1 2
1
2
1 2 1
2

output:

0
1
2
2
1
0
2
0
0
2
0
2
0
2
2
2
1
2

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 8
Accepted
time: 68ms
memory: 4092kb

input:

0
10
996 1000
0 1
2 0
1 3
4 1
5 2
6 2
7 3
3 8
4 9
10 4
11 5
12 5
6 13
14 6
7 15
7 16
17 8
18 8
19 9
9 20
21 10
10 22
23 11
24 11
12 25
26 12
27 13
13 28
14 29
30 14
15 31
15 32
16 33
34 16
35 17
17 36
18 37
38 18
39 19
40 19
41 20
42 20
43 21
44 21
45 22
46 22
23 47
48 23
49 24
24 50
25 51
52 25
26 ...

output:

996
0
511
995
1
256
512
767
128
255
383
510
639
766
894
994
2
65
129
192
257
320
384
447
513
576
640
703
768
831
895
958
33
64
96
127
160
191
223
254
288
319
351
382
415
446
478
509
544
575
607
638
671
702
734
765
799
830
862
893
926
957
978
993
3
18
34
49
66
81
97
112
130
145
161
176
193
208
224
23...

input:

1
50252
729 381 1
727
852 130 1
851
986 523 1
987
409 385 1
408
857 222 1
855
421 924 1
420
707 713 1
705
434 778 1
432
712 753 3
713
714
718
870 463 3
863
864
867
992 15 1
993
596 143 3
597
598
599
782 516 1
780
403 922 1
401
291 0 1
290
71 147 1
70
864 931 3
865
866
870
319 310 3
257
289
304
361 6...

output:

727
851
987
408
855
420
705
432
718
863
993
599
780
401
290
70
870
304
360
960
935
864
712
160
375
915
209
758
683
926
895
885
773
360
289
505
609
769
300
459
854
408
981
903
414
48
168
687
840
137
168
368
922
53
839
976
332
938
630
231
686
900
187
442
864
649
447
101
266
212
751
687
600
95
996
894
...

result:

ok 

Test #12:

score: 8
Accepted
time: 50ms
memory: 3824kb

input:

0
10
31 1000
0 1
0 2
3 1
4 1
2 5
6 2
7 3
3 8
4 9
4 10
11 5
5 12
13 6
6 14
15 7
16 7
17 8
18 8
9 19
20 9
10 21
22 10
11 23
11 24
12 25
26 12
13 27
28 13
14 29
14 30
128 1000
0 1
2 0
3 1
4 1
5 2
6 2
3 7
8 3
9 4
10 4
11 5
12 5
6 13
6 14
7 15
16 7
17 8
18 8
19 9
20 9
10 21
22 10
11 23
11 24
12 25
26 12
...

output:

31
0
15
30
1
8
16
23
4
7
11
14
19
22
26
29
2
3
5
6
9
10
12
13
17
18
20
21
24
25
27
28
128
0
64
127
1
33
65
96
17
32
48
63
80
95
111
126
2
10
18
25
34
41
49
56
66
73
81
88
97
104
112
119
6
9
13
16
21
24
28
31
37
40
44
47
52
55
59
62
69
72
76
79
84
87
91
94
100
103
107
110
115
118
122
125
3
5
7
8
11
1...

input:

1
59568
11 23 3
8
9
10
435 275 3
436
437
438
26 351 3
29
32
33
336 397 3
339
342
350
84 71 3
81
82
83
0 2 2
1
2
26 15 1
28
307 415 3
304
305
306
238 328 3
232
236
237
0 2 2
2
3
221 261 3
215
219
220
3 2 1
0
390 381 1
391
3 1 1
0
1 0 1
0
96 48 3
99
102
110
22 51 1
23
115 9 1
117
185 751 1
184
146 153...

output:

8
438
33
350
81
2
28
304
232
2
215
0
391
0
0
110
23
117
184
160
1
8
645
315
34
73
28
0
101
17
0
125
1
1
1
0
350
7
55
482
0
3
623
791
1
0
219
222
1
1
768
17
180
0
1
3
1
15
0
223
0
0
483
84
0
363
356
1
66
66
2
0
15
258
0
1
106
434
149
508
0
31
847
950
0
20
495
1
10
321
12
0
73
22
8
1
960
25
87
95
274
...

result:

ok 

Test #13:

score: 8
Accepted
time: 42ms
memory: 3732kb

input:

0
10
2 1000
1 0
2 1000
0 1
2 1000
0 1
2 1000
1 0
2 1000
0 1
2 1000
0 1
2 1000
0 1
2 1000
1 0
2 1000
1 0
2 1000
1 0

output:

2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1
2
0
1

input:

1
100000
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
1 0 1
0
0 1 1
1
0 1 1
1
0 1 1
1
1 0 1
0
0 1 1
1
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
1 0 1
0
1 0 1
0
0 1 1
1
1 0...

output:

1
0
0
1
1
0
0
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
1
0
1
1
1
0
1
1
0
0
1
0
0
1
0
0
0
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
0
1
1
0
0
1
0
1
0
0
1
0
0
1
1
0
1
0
1
0
0
1
0
0
0
1
1
1
1
0
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
1
1
1
1
1
1
1
0
0
0
1
0
1
1
0
1
1
0
0
0
0
0
1
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
0
1
1
1
1
0
0
1
0
0
0
0
0
...

result:

ok 

Test #14:

score: 8
Accepted
time: 40ms
memory: 4096kb

input:

0
10
3 1000
1 0
2 0
3 1000
0 1
2 0
3 1000
1 0
2 0
3 1000
0 1
0 2
3 1000
0 1
0 2
3 1000
1 0
2 0
3 1000
0 1
0 2
3 1000
1 0
0 2
3 1000
0 1
2 0
3 1000
1 0
0 2

output:

3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2
3
0
1
2

input:

1
74831
1 2 1
0
0 2 2
1
2
1 0 1
0
0 1 2
1
2
2 1 1
0
2 0 1
0
0 2 2
1
2
0 2 2
1
2
0 1 2
1
2
1 2 1
0
0 2 2
1
2
1 0 1
0
0 1 2
1
2
1 0 1
0
2 1 1
0
0 2 2
1
2
0 2 2
1
2
0 2 2
1
2
0 1 2
1
2
0 1 2
1
2
1 2 1
0
1 2 1
0
2 1 1
0
2 0 1
0
2 1 1
0
1 2 1
0
0 2 2
1
2
1 2 1
0
2 0 1
0
1 0 1
0
2 0 1
0
2 0 1
0
0 1 2
1
2
...

output:

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

result:

ok 

Test #15:

score: 0
Wrong Answer
time: 34ms
memory: 3812kb

input:

0
10
4 1000
0 1
0 2
3 1
4 1000
0 1
0 2
1 3
4 1000
1 0
2 0
1 3
4 1000
0 1
2 0
3 1
4 1000
1 0
2 0
1 3
4 1000
0 1
2 0
1 3
4 1000
1 0
2 0
1 3
4 1000
1 0
0 2
3 1
4 1000
1 0
2 0
1 3
4 1000
0 1
2 0
1 3

output:

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

input:


output:


result:

wrong output format Output file not found: ""

Subtask #3:

score: 0
Channel 1 Judgement Failed

Test #17:

score: 0
Channel 1 Judgement Failed

input:


output:


input:


output:


result:


Subtask #4:

score: 0
Channel 1 Judgement Failed

Test #34:

score: 0
Channel 1 Judgement Failed

input:


output:


input:


output:


result:


Subtask #5:

score: 0
Channel 1 Judgement Failed

Test #54:

score: 0
Channel 1 Judgement Failed

input:


output:


input:


output:


result: