#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
vector<int> graph[maxn], L;
int timer = 0;
void dfs(int u, int p, int d) {
if(!d) L[u] = timer++;
for(int &v : graph[u]) if(v != p) dfs(v, u, d ^ 1);
if(d) L[u] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0; i<n; i++) graph[i].clear(), timer = 0;
for(int i=0; i<n-1; i++) {
graph[u[i]].push_back(v[i]);
graph[v[i]].push_back(u[i]);
}
L.clear();
L.resize(n);
dfs(0, 0, 0);
return L;
}
int find_next_station(int s, int t, vector<int> c) {
if(c[0] < s) {
if(s < t || t < c[0]) return c[0];
return c[upper_bound(c.begin(), c.end(), t)-c.begin()-1];
}
if(c.back() < t || t < s) return c.back();
return c[lower_bound(c.begin(), c.end(), t)-c.begin()];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
940 KB |
Output is correct |
2 |
Correct |
230 ms |
940 KB |
Output is correct |
3 |
Correct |
498 ms |
684 KB |
Output is correct |
4 |
Correct |
346 ms |
684 KB |
Output is correct |
5 |
Correct |
356 ms |
684 KB |
Output is correct |
6 |
Correct |
232 ms |
688 KB |
Output is correct |
7 |
Correct |
262 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
260 ms |
684 KB |
Output is correct |
2 |
Correct |
285 ms |
684 KB |
Output is correct |
3 |
Correct |
466 ms |
684 KB |
Output is correct |
4 |
Correct |
368 ms |
684 KB |
Output is correct |
5 |
Correct |
341 ms |
684 KB |
Output is correct |
6 |
Correct |
256 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
302 ms |
684 KB |
Output is correct |
2 |
Correct |
223 ms |
684 KB |
Output is correct |
3 |
Correct |
509 ms |
684 KB |
Output is correct |
4 |
Correct |
383 ms |
684 KB |
Output is correct |
5 |
Correct |
355 ms |
684 KB |
Output is correct |
6 |
Correct |
276 ms |
684 KB |
Output is correct |
7 |
Correct |
246 ms |
688 KB |
Output is correct |
8 |
Correct |
0 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
760 KB |
Output is correct |
11 |
Correct |
378 ms |
684 KB |
Output is correct |
12 |
Correct |
268 ms |
1044 KB |
Output is correct |
13 |
Correct |
257 ms |
932 KB |
Output is correct |
14 |
Correct |
260 ms |
684 KB |
Output is correct |
15 |
Correct |
21 ms |
768 KB |
Output is correct |
16 |
Correct |
35 ms |
768 KB |
Output is correct |
17 |
Correct |
52 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
501 ms |
684 KB |
Output is correct |
2 |
Correct |
381 ms |
684 KB |
Output is correct |
3 |
Correct |
335 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
764 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
768 KB |
Output is correct |
7 |
Correct |
341 ms |
688 KB |
Output is correct |
8 |
Correct |
546 ms |
684 KB |
Output is correct |
9 |
Correct |
420 ms |
680 KB |
Output is correct |
10 |
Correct |
335 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
2 ms |
772 KB |
Output is correct |
13 |
Correct |
2 ms |
764 KB |
Output is correct |
14 |
Correct |
1 ms |
768 KB |
Output is correct |
15 |
Correct |
0 ms |
768 KB |
Output is correct |
16 |
Correct |
271 ms |
716 KB |
Output is correct |
17 |
Correct |
279 ms |
684 KB |
Output is correct |
18 |
Correct |
324 ms |
684 KB |
Output is correct |
19 |
Correct |
230 ms |
684 KB |
Output is correct |
20 |
Correct |
298 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
299 ms |
940 KB |
Output is correct |
2 |
Correct |
236 ms |
944 KB |
Output is correct |
3 |
Correct |
514 ms |
684 KB |
Output is correct |
4 |
Correct |
396 ms |
684 KB |
Output is correct |
5 |
Correct |
331 ms |
684 KB |
Output is correct |
6 |
Correct |
257 ms |
684 KB |
Output is correct |
7 |
Correct |
234 ms |
684 KB |
Output is correct |
8 |
Correct |
0 ms |
764 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
217 ms |
684 KB |
Output is correct |
12 |
Correct |
298 ms |
684 KB |
Output is correct |
13 |
Correct |
489 ms |
936 KB |
Output is correct |
14 |
Correct |
344 ms |
684 KB |
Output is correct |
15 |
Correct |
340 ms |
688 KB |
Output is correct |
16 |
Correct |
252 ms |
684 KB |
Output is correct |
17 |
Correct |
343 ms |
684 KB |
Output is correct |
18 |
Correct |
261 ms |
932 KB |
Output is correct |
19 |
Correct |
244 ms |
932 KB |
Output is correct |
20 |
Correct |
242 ms |
680 KB |
Output is correct |
21 |
Correct |
30 ms |
768 KB |
Output is correct |
22 |
Correct |
34 ms |
740 KB |
Output is correct |
23 |
Correct |
51 ms |
744 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
764 KB |
Output is correct |
26 |
Correct |
2 ms |
764 KB |
Output is correct |
27 |
Correct |
1 ms |
768 KB |
Output is correct |
28 |
Correct |
0 ms |
768 KB |
Output is correct |
29 |
Correct |
276 ms |
804 KB |
Output is correct |
30 |
Correct |
292 ms |
684 KB |
Output is correct |
31 |
Correct |
279 ms |
684 KB |
Output is correct |
32 |
Correct |
294 ms |
684 KB |
Output is correct |
33 |
Correct |
308 ms |
684 KB |
Output is correct |
34 |
Correct |
170 ms |
684 KB |
Output is correct |
35 |
Correct |
262 ms |
1064 KB |
Output is correct |
36 |
Correct |
248 ms |
932 KB |
Output is correct |
37 |
Correct |
266 ms |
784 KB |
Output is correct |
38 |
Correct |
294 ms |
808 KB |
Output is correct |
39 |
Correct |
238 ms |
1048 KB |
Output is correct |
40 |
Correct |
236 ms |
792 KB |
Output is correct |
41 |
Correct |
254 ms |
784 KB |
Output is correct |
42 |
Correct |
31 ms |
764 KB |
Output is correct |
43 |
Correct |
40 ms |
764 KB |
Output is correct |
44 |
Correct |
69 ms |
760 KB |
Output is correct |
45 |
Correct |
72 ms |
736 KB |
Output is correct |
46 |
Correct |
164 ms |
684 KB |
Output is correct |
47 |
Correct |
177 ms |
684 KB |
Output is correct |
48 |
Correct |
23 ms |
776 KB |
Output is correct |
49 |
Correct |
27 ms |
808 KB |
Output is correct |