QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#140492#1139. StationsQwerty12320 32ms3756kbC++201.5kb2023-08-16 00:39:572023-08-16 00:39:59

Judging History

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

  • [2023-08-16 00:39:59]
  • 评测
  • 测评结果:0
  • 用时:32ms
  • 内存:3756kb
  • [2023-08-16 00:39:57]
  • 提交

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);
    auto dfs = [&](auto dfs, int v, int f, int d, int& e) -> void {
        for (int t : gr[v]) {
            if (t != f) {
                dfs(dfs, t, v, d + 1, e);
            }
        }
        res[v] = e++;
    };
    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;
    std::vector<std::vector<int>> gr(n);
    for (int i = 1; i < n; i++) {
        gr[i / 2].push_back(i + 1);
        gr[i + 1].push_back(i / 2);
    }
    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, s, t)) {
            return t;
        }
    }

    assert(false);
}

详细

Subtask #1:

score: 0
Stage 2: Program stations Runtime Error

Test #1:

score: 0
Stage 2: Program stations Runtime Error

input:

10
10 1000
4 5
9 0
2 6
5 2
8 3
1 4
8 1
6 0
3 7
5575
4 6 5
7 3 3
6 0 0
8 5 1
7 1 3
0 4 6
0 5 6
0 8 6
1 6 4
4 5 5
4 8 1
4 3 1
8 9 1
4 8 1
2 7 5
4 6 5
6 9 0
6 9 0
8 0 1
7 2 3
1 0 4
1 8 8
7 2 3
6 8 2
6 8 2
9 6 0
6 0 0
0 9 9
2 5 5
9 6 0
2 0 6
0 9 9
2 9 6
3 6 8
2 0 6
0 1 6
5 8 4
1 2 4
1 6 4
3 6 8
6 4 2
0 ...

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:


output:


result:


Subtask #2:

score: 0
Stage 2: Program stations Runtime Error

Test #11:

score: 0
Stage 2: Program stations Runtime Error

input:

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 53...

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:


output:


result:


Subtask #3:

score: 0
Stage 2: Program stations Runtime Error

Test #17:

score: 0
Stage 2: Program stations Runtime Error

input:

10
2 1000000
1 0
10000
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
0 1 1
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
0 1 1
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
0 1 1
1 0 0
0 1 1
1 0 0
1 0 0
0 1 1
1 0 0
0 1 1
1...

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:


output:


result:


Subtask #4:

score: 0
Stage 2: Program stations Runtime Error

Test #34:

score: 10
Accepted
time: 32ms
memory: 3756kb

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 Runtime Error

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
Stage 2: Program stations Runtime Error

Test #54:

score: 0
Stage 2: Program stations Runtime Error

input:

10
3 1000000000
1 0
2 1
7507
1 2 2
2 0 1
1 2 2
1 2 2
1 2 2
0 2 1
0 2 1
2 1 1
2 1 1
0 2 1
1 0 0
1 0 0
1 0 0
2 0 1
1 0 0
0 1 1
0 1 1
0 2 1
2 0 1
2 0 1
2 0 1
0 2 1
2 0 1
1 0 0
2 0 1
0 1 1
2 0 1
1 2 2
2 0 1
0 2 1
0 2 1
0 2 1
0 2 1
2 0 1
0 1 1
2 0 1
0 1 1
0 2 1
0 2 1
2 0 1
2 0 1
1 2 2
0 2 1
2 0 1
2 0 1
2...

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:


output:


result: