#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
vector<int> G[maxn], L;
int T = 0;
void dfs(int u, int p, int d) {
if(!d) L[u] = T++;
for(int &v : G[u]) if(v != p) dfs(v, u, d ^ 1);
if(d) L[u] = T++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0; i<n; i++) G[i].clear(), T = 0;
for(int i=0; i<n-1; i++) {
G[u[i]].push_back(v[i]);
G[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 |
330 ms |
684 KB |
Output is correct |
2 |
Correct |
248 ms |
684 KB |
Output is correct |
3 |
Correct |
546 ms |
684 KB |
Output is correct |
4 |
Correct |
360 ms |
684 KB |
Output is correct |
5 |
Correct |
383 ms |
684 KB |
Output is correct |
6 |
Correct |
230 ms |
684 KB |
Output is correct |
7 |
Correct |
246 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
213 ms |
684 KB |
Output is correct |
2 |
Correct |
309 ms |
684 KB |
Output is correct |
3 |
Correct |
504 ms |
684 KB |
Output is correct |
4 |
Correct |
404 ms |
684 KB |
Output is correct |
5 |
Correct |
349 ms |
684 KB |
Output is correct |
6 |
Correct |
269 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
289 ms |
940 KB |
Output is correct |
2 |
Correct |
272 ms |
688 KB |
Output is correct |
3 |
Correct |
542 ms |
684 KB |
Output is correct |
4 |
Correct |
413 ms |
684 KB |
Output is correct |
5 |
Correct |
322 ms |
684 KB |
Output is correct |
6 |
Correct |
276 ms |
684 KB |
Output is correct |
7 |
Correct |
255 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Correct |
341 ms |
684 KB |
Output is correct |
12 |
Correct |
261 ms |
796 KB |
Output is correct |
13 |
Correct |
255 ms |
1040 KB |
Output is correct |
14 |
Correct |
242 ms |
684 KB |
Output is correct |
15 |
Correct |
21 ms |
768 KB |
Output is correct |
16 |
Correct |
26 ms |
776 KB |
Output is correct |
17 |
Correct |
51 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
507 ms |
684 KB |
Output is correct |
2 |
Correct |
403 ms |
684 KB |
Output is correct |
3 |
Correct |
342 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
776 KB |
Output is correct |
5 |
Correct |
2 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
776 KB |
Output is correct |
7 |
Correct |
324 ms |
788 KB |
Output is correct |
8 |
Correct |
508 ms |
684 KB |
Output is correct |
9 |
Correct |
371 ms |
684 KB |
Output is correct |
10 |
Correct |
363 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
764 KB |
Output is correct |
12 |
Correct |
2 ms |
764 KB |
Output is correct |
13 |
Correct |
2 ms |
776 KB |
Output is correct |
14 |
Correct |
1 ms |
776 KB |
Output is correct |
15 |
Correct |
1 ms |
776 KB |
Output is correct |
16 |
Correct |
291 ms |
684 KB |
Output is correct |
17 |
Correct |
261 ms |
944 KB |
Output is correct |
18 |
Correct |
293 ms |
684 KB |
Output is correct |
19 |
Correct |
267 ms |
684 KB |
Output is correct |
20 |
Correct |
289 ms |
692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
310 ms |
940 KB |
Output is correct |
2 |
Correct |
263 ms |
684 KB |
Output is correct |
3 |
Correct |
493 ms |
684 KB |
Output is correct |
4 |
Correct |
347 ms |
684 KB |
Output is correct |
5 |
Correct |
355 ms |
684 KB |
Output is correct |
6 |
Correct |
239 ms |
684 KB |
Output is correct |
7 |
Correct |
236 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
776 KB |
Output is correct |
9 |
Correct |
1 ms |
776 KB |
Output is correct |
10 |
Correct |
0 ms |
780 KB |
Output is correct |
11 |
Correct |
245 ms |
684 KB |
Output is correct |
12 |
Correct |
305 ms |
684 KB |
Output is correct |
13 |
Correct |
504 ms |
684 KB |
Output is correct |
14 |
Correct |
372 ms |
684 KB |
Output is correct |
15 |
Correct |
333 ms |
684 KB |
Output is correct |
16 |
Correct |
266 ms |
684 KB |
Output is correct |
17 |
Correct |
316 ms |
684 KB |
Output is correct |
18 |
Correct |
240 ms |
792 KB |
Output is correct |
19 |
Correct |
252 ms |
784 KB |
Output is correct |
20 |
Correct |
252 ms |
684 KB |
Output is correct |
21 |
Correct |
23 ms |
768 KB |
Output is correct |
22 |
Correct |
31 ms |
768 KB |
Output is correct |
23 |
Correct |
56 ms |
688 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
1 ms |
768 KB |
Output is correct |
26 |
Correct |
1 ms |
776 KB |
Output is correct |
27 |
Correct |
1 ms |
776 KB |
Output is correct |
28 |
Correct |
0 ms |
776 KB |
Output is correct |
29 |
Correct |
250 ms |
800 KB |
Output is correct |
30 |
Correct |
257 ms |
684 KB |
Output is correct |
31 |
Correct |
305 ms |
684 KB |
Output is correct |
32 |
Correct |
309 ms |
684 KB |
Output is correct |
33 |
Correct |
294 ms |
684 KB |
Output is correct |
34 |
Correct |
195 ms |
684 KB |
Output is correct |
35 |
Correct |
254 ms |
1188 KB |
Output is correct |
36 |
Correct |
254 ms |
1188 KB |
Output is correct |
37 |
Correct |
292 ms |
876 KB |
Output is correct |
38 |
Correct |
265 ms |
684 KB |
Output is correct |
39 |
Correct |
236 ms |
940 KB |
Output is correct |
40 |
Correct |
251 ms |
932 KB |
Output is correct |
41 |
Correct |
230 ms |
804 KB |
Output is correct |
42 |
Correct |
24 ms |
768 KB |
Output is correct |
43 |
Correct |
46 ms |
716 KB |
Output is correct |
44 |
Correct |
57 ms |
684 KB |
Output is correct |
45 |
Correct |
75 ms |
768 KB |
Output is correct |
46 |
Correct |
156 ms |
684 KB |
Output is correct |
47 |
Correct |
159 ms |
744 KB |
Output is correct |
48 |
Correct |
22 ms |
768 KB |
Output is correct |
49 |
Correct |
22 ms |
768 KB |
Output is correct |