QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140502#1139. StationsQwerty12320 222ms3864kbC++201.6kb2023-08-16 00:54:332023-08-16 00:54:34

Judging History

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

  • [2023-08-16 00:54:34]
  • 评测
  • 测评结果:0
  • 用时:222ms
  • 内存:3864kb
  • [2023-08-16 00:54:33]
  • 提交

stations

#include "stations.h"

#include <bits/stdc++.h>

#include <cassert>
#include <vector>

constexpr int N = 1e3;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    std::vector<std::vector<int>> gr(n);
    for (int i = 0; i < n - 1; i++) {
        gr[u[i]].push_back(v[i]);
        gr[v[i]].push_back(u[i]);
    }
    std::vector<int> res(n);

    for (int i = 0; i < n; i++) {
        res[i] = i;
    }

    return res;
}

int find_next_station(int s, int dest, std::vector<int> c) {
    assert(s != dest);
    for (int to : c) {
        if (to == dest) {
            return to;
        }
    }
    // if (c.size() == 1) {
    //     return c.front();
    // }

    int n = N + 10;
    static std::vector<std::vector<int>> gr;
    if (gr.size() == 0) {
        gr.assign(n, {});
        for (int i = 0; i < n; i++) {
            int u = i;

            if (2 * i < n) {
                int v = 2 * i;
                gr[u].push_back(v);
                gr[v].push_back(u);
            }
            if (2 * i + 1 < n) {
                int v = 2 * i + 1;
                gr[u].push_back(v);
                gr[v].push_back(u);
            }
        }
    }
    auto dfs = [&](auto dfs, int v, int f) -> bool {
        if (v == dest) {
            return true;
        }
        for (int t : gr[v]) {
            if (t != f) {
                if (dfs(dfs, t, v)) {
                    return true;
                }
            }
        }
        return false;
    };
    for (int t : c) {
        if (dfs(dfs, t, s)) {
            return t;
        }
    }

    assert(false);
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 164ms
memory: 3748kb

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
1
2
3
4
5
6
7
8
9
3
0
1
2
998
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91...

input:

1
59784
0 1 1
1
564 432 2
156
710
0 1 1
1
303 620 2
302
304
3 2 1
2
1 0 1
0
0 1 1
1
980 381 2
82
733
2 0 2
1
3
0 1 1
1
948 832 2
947
949
6 2 2
0
2
505 151 2
251
786
131 800 2
130
132
927 964 2
98
390
570 874 2
569
571
0 1 1
1
78 91 2
33
85
1 2 2
0
2
0 1 1
1
117 822 2
124
961
1 0 1
0
953 952 2
179
78...

output:

1
156
1
302
2
0
1
82
1
1
947
2
251
130
98
569
1
33
2
1
124
0
179
1
1
588
2
0
0
49
75
277
2
6
27
0
639
40
6
1
6
27
343
741
41
872
30
162
248
21
1
513
298
0
1
1
0
695
1
0
0
0
665
364
934
16
129
0
0
10
340
445
145
0
424
251
1
2
268
1
2
363
1
555
1
3
160
270
6
6
6
1
0
2
2
205
387
277
1
133
788
624
0
52
...

result:

wrong answer Diff at 2-th number: read 156 but expected 710

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 222ms
memory: 3864kb

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
10...

input:

1
50252
876 174 1
437
937 71 1
468
508 771 1
253
715 87 1
357
940 154 1
469
721 974 1
360
864 867 1
431
728 899 1
363
433 888 3
216
867
868
235 92 3
117
471
472
508 517 1
253
404 582 3
201
809
810
902 767 1
450
712 486 1
355
655 0 1
327
545 583 1
272
471 488 3
235
943
944
40 666 3
19
81
82
691 417 1...

output:

437
468
253
357
469
360
431
363
216
117
253
201
450
355
327
272
235
19
345
495
489
471
433
35
349
484
307
445
426
59
29
237
448
345
81
382
407
111
330
370
233
357
126
239
178
132
147
106
465
143
147
347
486
268
231
61
338
490
205
155
212
480
302
366
471
417
22
280
321
308
443
106
405
138
14
13
461
3...

result:

wrong answer Diff at 18-th number: read 19 but expected 82

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 146ms
memory: 3764kb

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
0
1
997
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
...

input:

1
59859
4 7 2
0
3
1 0 1
0
1 0 1
0
31 85 2
30
32
759 223 2
528
969
759 960 2
237
627
0 1 1
1
1 0 2
2
5
122 328 2
121
123
0 1 1
1
0 1 1
1
1 0 1
0
1 2 2
0
2
838 639 2
275
593
371 213 2
370
372
511 503 2
510
512
9 5 2
3
8
2 1 1
1
741 442 2
539
861
69 96 2
19
53
989 291 2
580
804
836 205 2
682
782
773 72...

output:

0
0
0
30
528
237
1
5
121
1
1
0
2
275
370
510
3
1
539
19
580
682
289
125
2
736
86
90
1
0
239
0
354
1
0
2
535
324
427
2
149
276
706
642
8
1
60
505
151
2
27
1
75
468
21
124
1
6
0
0
1
4
4
37
780
830
54
1
318
1
266
148
5
1
544
0
94
752
2
145
1
315
519
1
1
49
1
239
1
693
4
1
1
1
469
4
1
1
224
1
904
0
342
...

result:

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

Subtask #4:

score: 0
Stage 2: Program stations Dangerous Syscalls

Test #34:

score: 10
Accepted
time: 54ms
memory: 3696kb

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

output:

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

result:

ok 

Test #35:

score: 0
Stage 2: Program stations Dangerous Syscalls

input:

10
3 1000000000
2 1
2 0
7475
1 0 2
1 2 2
2 1 1
0 2 2
2 0 0
0 1 2
1 2 2
2 1 1
0 2 2
1 0 2
0 2 2
0 2 2
0 2 2
0 2 2
2 0 0
1 2 2
2 1 1
1 0 2
0 1 2
0 1 2
0 1 2
1 0 2
1 2 2
2 1 1
0 1 2
1 2 2
1 0 2
0 2 2
2 1 1
1 0 2
2 1 1
0 2 2
0 1 2
1 0 2
2 1 1
1 0 2
2 1 1
1 0 2
1 0 2
1 0 2
1 2 2
1 2 2
0 1 2
1 0 2
1 0 2
1...

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:


output:


result:


Subtask #5:

score: 0
Wrong Answer

Test #54:

score: 0
Wrong Answer
time: 150ms
memory: 3748kb

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
0
1
2
998
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
9...

input:

1
59797
2 3 2
1
3
661 819 2
33
571
1 0 1
0
66 46 2
73
82
521 664 2
195
865
1 0 2
0
2
1 3 2
0
2
155 678 2
584
628
70 125 2
55
796
958 547 2
37
500
0 1 1
1
237 589 2
418
886
25 605 2
537
570
756 219 2
264
618
1 0 2
0
2
506 607 2
365
676
515 917 2
514
516
16 13 2
31
74
7 4 2
4
5
175 645 2
174
176
942 1...

output:

3
33
0
73
195
0
0
584
55
37
1
418
537
264
0
365
514
31
4
174
941
0
1
104
846
905
200
649
164
1
0
212
395
1
462
63
134
85
2
0
1
1
142
14
0
887
693
819
883
7
1
579
125
0
2
755
112
1
540
1
2
465
0
2
600
171
1
219
221
6
33
167
196
348
173
816
2
922
116
260
1
437
1
1
4
341
319
154
1
1
21
1
7
558
2
1
58
2...

result:

wrong answer Diff at 4-th number: read 73 but expected 82