#include <bits/stdc++.h>
using namespace std;
const int N = 1007;
vector<int> g[N];
int a[N], b[N], C, dep[N];
void dfs(int v,int d = 0, int p =-1){
a[v] = C++;
dep[v] = d;
for(int u : g[v]){
if (u!= p) {
dfs(u, d + 1, v);
}
}
b[v] = C++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for (int i = 0;i < n; i++) g[i].clear();
for (int i = 0;i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
C = 0;
dfs(0);
vector<int> L(n);
for(int i =0 ; i < n ; i++) L[i] = (dep[i]&1) ? b[i] : a[i];
return L;
}
int find_next_station(int s, int t, vector<int> c) {
for (int v : c) {
if (v == t) return v;
}
bool f = 1;
for (int v : c) f &= v > s;
if (f) {
int lst = s;
for (int i = 0; i < c.size(); i++) {
if (i == (int)c.size() - 1) return c[i];
if (t > lst && t < c[i]) return c[i];
lst = c[i];
}
assert(0);
return -1;
}
int lst = s;
for (int i = (int)c.size() - 1; i >= 0; i--){
if (i == 0) return c[i];
if (t < lst && t > c[i]) return c[i];
lst = c[i];
}
assert(0);
return -1;
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int i = 0; i < c.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
492 KB |
Invalid labels (values out of range). scenario=2, k=1000, vertex=1, label=1990 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
364 KB |
Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1022 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
572 ms |
864 KB |
Output is correct |
2 |
Correct |
493 ms |
992 KB |
Output is correct |
3 |
Correct |
1059 ms |
736 KB |
Output is correct |
4 |
Correct |
814 ms |
864 KB |
Output is correct |
5 |
Correct |
790 ms |
884 KB |
Output is correct |
6 |
Correct |
504 ms |
992 KB |
Output is correct |
7 |
Correct |
527 ms |
1100 KB |
Output is correct |
8 |
Correct |
3 ms |
940 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
940 KB |
Output is correct |
11 |
Correct |
615 ms |
1068 KB |
Output is correct |
12 |
Correct |
510 ms |
1248 KB |
Output is correct |
13 |
Correct |
528 ms |
1000 KB |
Output is correct |
14 |
Correct |
523 ms |
864 KB |
Output is correct |
15 |
Correct |
52 ms |
736 KB |
Output is correct |
16 |
Correct |
94 ms |
864 KB |
Output is correct |
17 |
Correct |
130 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
923 ms |
808 KB |
Output is correct |
2 |
Correct |
760 ms |
736 KB |
Output is correct |
3 |
Correct |
716 ms |
864 KB |
Output is correct |
4 |
Correct |
3 ms |
864 KB |
Output is correct |
5 |
Correct |
5 ms |
776 KB |
Output is correct |
6 |
Correct |
2 ms |
736 KB |
Output is correct |
7 |
Correct |
677 ms |
736 KB |
Output is correct |
8 |
Correct |
1325 ms |
864 KB |
Output is correct |
9 |
Correct |
754 ms |
864 KB |
Output is correct |
10 |
Correct |
668 ms |
864 KB |
Output is correct |
11 |
Correct |
6 ms |
940 KB |
Output is correct |
12 |
Correct |
6 ms |
940 KB |
Output is correct |
13 |
Correct |
5 ms |
736 KB |
Output is correct |
14 |
Correct |
4 ms |
736 KB |
Output is correct |
15 |
Correct |
2 ms |
864 KB |
Output is correct |
16 |
Correct |
630 ms |
736 KB |
Output is correct |
17 |
Correct |
533 ms |
940 KB |
Output is correct |
18 |
Correct |
614 ms |
864 KB |
Output is correct |
19 |
Correct |
557 ms |
864 KB |
Output is correct |
20 |
Correct |
686 ms |
864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
599 ms |
1148 KB |
Partially correct |
2 |
Partially correct |
621 ms |
992 KB |
Partially correct |
3 |
Correct |
923 ms |
864 KB |
Output is correct |
4 |
Correct |
748 ms |
864 KB |
Output is correct |
5 |
Correct |
632 ms |
896 KB |
Output is correct |
6 |
Partially correct |
546 ms |
864 KB |
Partially correct |
7 |
Partially correct |
511 ms |
864 KB |
Partially correct |
8 |
Correct |
3 ms |
812 KB |
Output is correct |
9 |
Correct |
5 ms |
864 KB |
Output is correct |
10 |
Correct |
1 ms |
736 KB |
Output is correct |
11 |
Partially correct |
608 ms |
864 KB |
Partially correct |
12 |
Partially correct |
729 ms |
820 KB |
Partially correct |
13 |
Correct |
999 ms |
896 KB |
Output is correct |
14 |
Correct |
770 ms |
940 KB |
Output is correct |
15 |
Correct |
753 ms |
864 KB |
Output is correct |
16 |
Partially correct |
502 ms |
864 KB |
Partially correct |
17 |
Correct |
728 ms |
992 KB |
Output is correct |
18 |
Partially correct |
496 ms |
1092 KB |
Partially correct |
19 |
Partially correct |
573 ms |
860 KB |
Partially correct |
20 |
Partially correct |
440 ms |
736 KB |
Partially correct |
21 |
Correct |
61 ms |
992 KB |
Output is correct |
22 |
Partially correct |
78 ms |
864 KB |
Partially correct |
23 |
Partially correct |
141 ms |
984 KB |
Partially correct |
24 |
Correct |
7 ms |
940 KB |
Output is correct |
25 |
Correct |
7 ms |
940 KB |
Output is correct |
26 |
Correct |
5 ms |
864 KB |
Output is correct |
27 |
Correct |
5 ms |
736 KB |
Output is correct |
28 |
Correct |
2 ms |
940 KB |
Output is correct |
29 |
Correct |
519 ms |
736 KB |
Output is correct |
30 |
Correct |
625 ms |
864 KB |
Output is correct |
31 |
Correct |
470 ms |
940 KB |
Output is correct |
32 |
Correct |
551 ms |
864 KB |
Output is correct |
33 |
Correct |
514 ms |
940 KB |
Output is correct |
34 |
Partially correct |
317 ms |
1008 KB |
Partially correct |
35 |
Partially correct |
589 ms |
1068 KB |
Partially correct |
36 |
Partially correct |
519 ms |
864 KB |
Partially correct |
37 |
Partially correct |
525 ms |
1204 KB |
Partially correct |
38 |
Partially correct |
505 ms |
1108 KB |
Partially correct |
39 |
Partially correct |
534 ms |
1112 KB |
Partially correct |
40 |
Partially correct |
505 ms |
1528 KB |
Partially correct |
41 |
Partially correct |
482 ms |
1100 KB |
Partially correct |
42 |
Partially correct |
82 ms |
896 KB |
Partially correct |
43 |
Partially correct |
93 ms |
864 KB |
Partially correct |
44 |
Partially correct |
126 ms |
992 KB |
Partially correct |
45 |
Partially correct |
176 ms |
992 KB |
Partially correct |
46 |
Partially correct |
324 ms |
864 KB |
Partially correct |
47 |
Partially correct |
391 ms |
932 KB |
Partially correct |
48 |
Partially correct |
83 ms |
1100 KB |
Partially correct |
49 |
Partially correct |
63 ms |
1112 KB |
Partially correct |