QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#498952#1139. StationsDan4Life#0 62ms4088kbC++23952b2024-07-30 22:09:352024-07-30 22:09:36

Judging History

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

  • [2024-07-30 22:09:36]
  • 评测
  • 测评结果:0
  • 用时:62ms
  • 内存:4088kb
  • [2024-07-30 22:09:35]
  • 提交

stations

#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 1010;
vi labels;
int dfs_timer = 0;
vi adj[mxN];

void dfs(int s, int p){
	for(auto u : adj[s])
		if(u!=p) dfs(u,s);
	labels[s] = dfs_timer++;
}

vi label(int n, int k, vi u, vi v) {
	labels.clear();
	labels.resize(n,0); dfs_timer=0;
	for(int i = 0; i < n; i++) adj[i].clear();
	for(int i = 0; i < sz(u); i++){
		int a = u[i], b = v[i];
		adj[a].pb(b), adj[b].pb(a);
	}
	dfs(0,-1);
	return labels;
}

int find_next_station(int s, int t, vi c) {
	if(sz(c)==1) return c[0];
	for(auto u : c) if(u==t) return u;
	if(t > s) return c.back();
	for(int i = 0; i < sz(c)-2; i++)
		if(c[i] < t and t < c[i+1]) return c[i+1];
	int sub0 = s-1-c[0];
	if(c[0]-sub0 <= t and t < c[0]) return c[0];
	return c.back();
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 28ms
memory: 4080kb

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
9
4
7
2
5
6
8
1
3
0
3
2
1
0
998
997
992
165
11
707
399
850
846
132
114
886
686
80
428
607
66
768
945
535
696
352
636
781
528
813
506
497
253
397
895
207
376
414
514
239
876
761
107
369
308
960
6
908
23
901
252
975
105
842
737
628
139
306
643
631
312
4
136
950
747
198
337
121
972
158
40
76
163
657...

input:

1
59784
1 0 1
0
686 598 2
685
687
1 0 1
0
696 379 2
695
697
0 1 1
1
0 1 1
1
1 0 1
0
485 112 2
484
486
1 3 2
0
2
3 2 1
2
51 167 2
50
52
8 7 2
7
9
27 777 2
26
28
868 199 2
867
869
619 746 2
618
620
429 125 2
428
430
1 0 1
0
53 87 2
52
54
1 0 2
0
2
1 0 1
0
296 92 2
295
297
0 1 1
1
533 724 2
532
534
1 0...

output:

0
687
0
697
1
1
0
486
2
2
52
7
28
869
620
430
0
54
0
0
297
1
534
0
1
6
1
1
2
739
1
722
1
8
86
1
391
7
8
2
8
510
552
998
10
536
790
105
447
60
1
521
701
3
1
1
3
606
1
9
2
1
609
458
65
34
65
3
1
283
294
967
584
1
414
63
1
1
987
0
1
332
1
433
1
24
839
694
8
8
8
1
99
7
1
267
410
338
1
158
211
375
1
763
...

result:

wrong answer Diff at 2-th number: read 687 but expected 685

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 32ms
memory: 4088kb

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
995
510
994
254
509
765
993
126
253
381
508
637
764
892
992
62
125
189
252
317
380
444
507
573
636
700
763
828
891
955
991
30
61
93
124
157
188
220
251
285
316
348
379
412
443
475
506
541
572
604
635
668
699
731
762
796
827
859
890
923
954
975
990
14
29
45
60
77
92
108
123
141
156
172
187
204
21...

input:

1
50252
724 377 1
725
847 141 1
849
982 518 1
983
404 396 1
406
852 218 1
853
416 919 1
418
702 708 1
703
429 773 1
430
710 748 3
708
709
714
866 474 3
862
865
874
988 10 1
989
594 138 3
592
593
595
777 511 1
778
398 920 1
399
286 995 1
288
66 142 1
68
862 929 3
860
861
866
316 305 3
300
315
317
356...

output:

725
849
983
406
853
418
703
430
714
874
989
595
778
399
288
68
866
315
358
958
933
862
710
157
373
913
207
756
681
923
955
881
771
358
300
503
607
780
298
457
850
406
984
899
410
44
164
698
838
133
164
366
920
51
835
973
330
936
626
227
682
898
185
440
862
647
507
99
264
210
749
698
598
91
994
892
8...

result:

wrong answer Diff at 2714-th number: read 498 but expected 504

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 36ms
memory: 3744kb

input:

0
10
2 1000000
1 0
997 1000000
830 513
223 672
727 200
763 415
581 440
34 42
267 325
912 693
753 59
401 289
198 641
982 214
41 49
453 107
940 806
905 732
153 482
248 405
102 79
480 837
534 620
564 856
679 178
278 247
899 206
333 672
297 308
407 863
26 752
272 178
204 603
208 10
715 562
785 285
184 5...

output:

2
1
0
997
996
612
436
285
792
563
338
572
483
827
204
749
973
233
379
407
923
979
818
912
702
378
681
426
691
889
193
75
243
464
968
841
788
523
258
488
467
637
781
157
909
706
259
628
724
275
56
94
358
707
591
751
565
133
561
129
913
65
254
148
277
295
251
0
850
930
512
876
63
228
861
291
821
1
853...

input:

1
59859
4 0 2
3
9
0 1 1
1
0 1 1
1
968 914 2
967
969
800 698 2
799
801
737 139 2
736
738
1 0 1
0
7 9 2
6
8
877 671 2
876
878
1 0 1
0
1 0 1
0
0 1 1
1
1 0 2
0
2
962 689 2
961
963
628 786 2
627
629
488 496 2
487
489
2 8 2
1
3
0 1 1
1
570 360 2
569
571
83 96 2
82
84
447 421 2
446
448
709 330 2
708
710
88...

output:

9
1
1
969
801
738
0
8
878
0
0
1
0
963
629
489
3
1
571
84
448
710
885
882
0
172
363
191
1
3
245
9
463
2
1
1
374
675
211
0
491
187
897
357
1
2
175
408
117
0
868
2
636
420
34
44
0
81
2
1
1
4
4
57
606
169
77
2
681
7
733
340
47
2
572
3
229
247
0
718
1
71
480
0
0
707
0
721
0
306
56
7
1
1
828
4
1
0
701
0
9...

result:

wrong answer Diff at 1-th number: read 9 but expected 3

Subtask #4:

score: 0
Wrong Answer

Test #34:

score: 10
Accepted
time: 62ms
memory: 4088kb

input:

0
10
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
1 0
2 1000000000
1 0
2 1000000000
0 1
2 1000000000
0 1
2 1000000000
0 1

output:

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

input:

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

output:

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

result:

ok 

Test #35:

score: 10
Accepted
time: 40ms
memory: 3748kb

input:

0
10
3 1000000000
2 1
2 0
3 1000000000
1 0
2 0
3 1000000000
2 0
0 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
1 0
2 1
3 1000000000
0 2
1 2
3 1000000000
1 2
1 0
3 1000000000
0 2
1 0
3 1000000000
2 0
1 2

output:

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

input:

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

output:

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

result:

ok 

Test #36:

score: 0
Wrong Answer
time: 36ms
memory: 4044kb

input:

0
10
4 1000000000
3 1
2 0
1 0
4 1000000000
0 3
1 2
3 1
4 1000000000
3 1
0 2
0 1
4 1000000000
2 1
2 3
1 0
4 1000000000
3 1
0 1
2 3
4 1000000000
0 1
3 0
2 3
4 1000000000
2 0
3 0
1 2
4 1000000000
0 2
2 3
1 3
4 1000000000
3 2
2 1
3 0
4 1000000000
2 3
3 0
0 1

output:

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

input:

1
66804
3 0 2
1
2
3 0 2
1
2
2 3 2
1
3
3 2 1
2
3 1 2
0
2
2 1 2
1
3
1 0 2
0
2
2 1 2
1
3
3 1 1
2
1 2 2
0
3
3 2 2
0
2
2 3 2
1
3
1 2 2
0
2
0 3 1
3
2 3 2
1
3
0 1 1
3
0 3 1
3
2 1 2
1
3
1 2 2
0
2
0 1 1
1
1 0 2
0
2
2 3 1
3
3 2 1
2
2 0 2
1
3
0 1 1
1
2 0 2
1
3
2 3 2
1
3
0 1 1
1
0 1 1
1
3 0 2
0
2
2 1 2
1
3
0 2 ...

output:

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

result:

wrong answer Diff at 24-th number: read 3 but expected 1

Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 36ms
memory: 4076kb

input:

0
10
3 1000000000
1 0
2 1
998 1000000000
928 443
90 795
55 379
957 417
759 300
960 136
309 858
833 370
228 827
876 955
619 365
15 108
243 388
54 925
141 894
272 634
0 989
600 346
380 277
350 113
326 613
975 946
660 98
34 538
220 864
9 585
185 860
458 424
509 14
22 275
109 872
153 233
76 834
972 736
...

output:

3
2
1
0
998
997
865
884
486
280
63
570
267
984
673
21
515
964
485
569
320
29
75
279
151
815
114
452
640
626
141
18
252
836
566
942
254
580
384
663
943
761
481
404
918
191
701
239
340
658
645
261
417
945
112
923
127
773
149
993
905
427
666
154
194
824
545
747
507
851
129
574
391
641
390
187
176
244
3...

input:

1
59797
1 0 2
0
2
227 133 2
226
228
0 1 1
1
28 61 2
27
29
273 565 2
272
274
2 3 2
1
3
2 0 2
1
3
879 583 2
878
880
541 943 2
540
542
567 417 2
566
568
1 0 1
0
256 248 2
255
257
362 365 2
361
363
950 756 2
949
951
1 2 2
0
2
813 211 2
812
814
484 82 2
483
485
87 73 2
86
88
3 2 2
2
4
824 354 2
823
825
5...

output:

0
228
1
29
274
3
3
880
542
568
0
257
363
951
2
814
485
88
2
825
58
1
2
926
14
94
653
810
550
0
2
787
912
1
744
83
109
771
44
1
1
0
744
867
1
112
306
133
942
3
0
40
222
2
6
244
314
0
778
2
0
727
9
8
399
379
2
253
257
11
3
823
803
354
826
352
0
77
221
610
1
71
1
2
4
628
456
795
0
2
114
1
3
441
0
0
989...

result:

wrong answer Diff at 2-th number: read 228 but expected 226