#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1005
vector<int> a[MAXN];
int pre[MAXN], h[MAXN];
int c;
void dfs(int x, int p) {
if(h[x]&1) pre[x] = c++;
for(auto i: a[x]) if(i != p) {h[i] = h[x] + 1; dfs(i, x);}
if(!(h[x]&1)) pre[x] = (c++);
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
c = 0; h[0] = 0;
for(int i = 0; i < MAXN; i++) a[i].clear();
std::vector<int> labels(n);
for(int i = 0; i < n - 1; i++) {
a[u[i]].push_back(v[i]);
a[v[i]].push_back(u[i]);
}
dfs(0, -1);
for (int i = 0; i < n; i++) labels[i]=pre[i];
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(s<c[0]) {
if(t < s) return end(c)[-1];
auto it = lower_bound(c.begin(),c.end(),t);
if(it == c.end()) return end(c)[-1];
return (*it);
} else {
if(t > s) return c[0];
auto it = upper_bound(c.begin(),c.end(),t);
if(it == c.begin()) return c[0];
return (*(--it));
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
365 ms |
924 KB |
Output is correct |
2 |
Correct |
321 ms |
920 KB |
Output is correct |
3 |
Correct |
517 ms |
684 KB |
Output is correct |
4 |
Correct |
411 ms |
940 KB |
Output is correct |
5 |
Correct |
407 ms |
684 KB |
Output is correct |
6 |
Correct |
267 ms |
908 KB |
Output is correct |
7 |
Correct |
293 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
864 KB |
Output is correct |
2 |
Correct |
323 ms |
820 KB |
Output is correct |
3 |
Correct |
539 ms |
684 KB |
Output is correct |
4 |
Correct |
446 ms |
688 KB |
Output is correct |
5 |
Correct |
449 ms |
684 KB |
Output is correct |
6 |
Correct |
292 ms |
936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
924 KB |
Output is correct |
2 |
Correct |
277 ms |
920 KB |
Output is correct |
3 |
Correct |
542 ms |
972 KB |
Output is correct |
4 |
Correct |
471 ms |
684 KB |
Output is correct |
5 |
Correct |
370 ms |
688 KB |
Output is correct |
6 |
Correct |
286 ms |
1092 KB |
Output is correct |
7 |
Correct |
321 ms |
864 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
387 ms |
684 KB |
Output is correct |
12 |
Correct |
301 ms |
976 KB |
Output is correct |
13 |
Correct |
286 ms |
1280 KB |
Output is correct |
14 |
Correct |
337 ms |
684 KB |
Output is correct |
15 |
Correct |
33 ms |
896 KB |
Output is correct |
16 |
Correct |
33 ms |
932 KB |
Output is correct |
17 |
Correct |
60 ms |
868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
605 ms |
684 KB |
Output is correct |
2 |
Correct |
427 ms |
684 KB |
Output is correct |
3 |
Correct |
394 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
764 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
392 ms |
684 KB |
Output is correct |
8 |
Correct |
536 ms |
684 KB |
Output is correct |
9 |
Correct |
420 ms |
684 KB |
Output is correct |
10 |
Correct |
373 ms |
684 KB |
Output is correct |
11 |
Correct |
4 ms |
764 KB |
Output is correct |
12 |
Correct |
3 ms |
880 KB |
Output is correct |
13 |
Correct |
2 ms |
768 KB |
Output is correct |
14 |
Correct |
3 ms |
808 KB |
Output is correct |
15 |
Correct |
0 ms |
800 KB |
Output is correct |
16 |
Correct |
285 ms |
684 KB |
Output is correct |
17 |
Correct |
343 ms |
684 KB |
Output is correct |
18 |
Correct |
323 ms |
720 KB |
Output is correct |
19 |
Correct |
346 ms |
684 KB |
Output is correct |
20 |
Correct |
367 ms |
944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
349 ms |
916 KB |
Output is correct |
2 |
Correct |
311 ms |
920 KB |
Output is correct |
3 |
Correct |
506 ms |
940 KB |
Output is correct |
4 |
Correct |
417 ms |
684 KB |
Output is correct |
5 |
Correct |
371 ms |
684 KB |
Output is correct |
6 |
Correct |
298 ms |
920 KB |
Output is correct |
7 |
Correct |
327 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
924 KB |
Output is correct |
11 |
Correct |
330 ms |
896 KB |
Output is correct |
12 |
Correct |
320 ms |
844 KB |
Output is correct |
13 |
Correct |
544 ms |
680 KB |
Output is correct |
14 |
Correct |
400 ms |
684 KB |
Output is correct |
15 |
Correct |
368 ms |
684 KB |
Output is correct |
16 |
Correct |
258 ms |
680 KB |
Output is correct |
17 |
Correct |
428 ms |
860 KB |
Output is correct |
18 |
Correct |
274 ms |
1156 KB |
Output is correct |
19 |
Correct |
268 ms |
1288 KB |
Output is correct |
20 |
Correct |
273 ms |
684 KB |
Output is correct |
21 |
Correct |
32 ms |
900 KB |
Output is correct |
22 |
Correct |
36 ms |
928 KB |
Output is correct |
23 |
Correct |
57 ms |
876 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
2 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
1 ms |
768 KB |
Output is correct |
29 |
Correct |
339 ms |
684 KB |
Output is correct |
30 |
Correct |
324 ms |
684 KB |
Output is correct |
31 |
Correct |
332 ms |
684 KB |
Output is correct |
32 |
Correct |
305 ms |
684 KB |
Output is correct |
33 |
Correct |
324 ms |
684 KB |
Output is correct |
34 |
Correct |
200 ms |
896 KB |
Output is correct |
35 |
Correct |
257 ms |
1056 KB |
Output is correct |
36 |
Correct |
301 ms |
1412 KB |
Output is correct |
37 |
Correct |
264 ms |
1260 KB |
Output is correct |
38 |
Correct |
273 ms |
1148 KB |
Output is correct |
39 |
Correct |
272 ms |
1016 KB |
Output is correct |
40 |
Correct |
320 ms |
1148 KB |
Output is correct |
41 |
Correct |
284 ms |
1008 KB |
Output is correct |
42 |
Correct |
32 ms |
1140 KB |
Output is correct |
43 |
Correct |
55 ms |
900 KB |
Output is correct |
44 |
Correct |
69 ms |
948 KB |
Output is correct |
45 |
Correct |
103 ms |
892 KB |
Output is correct |
46 |
Correct |
184 ms |
860 KB |
Output is correct |
47 |
Correct |
195 ms |
888 KB |
Output is correct |
48 |
Correct |
34 ms |
1172 KB |
Output is correct |
49 |
Correct |
33 ms |
1236 KB |
Output is correct |