#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
vector<int>label(n), h(n);
vector<vector<int>>e(n);
for(int i = 0; i + 1 < n; i++){
e[u[i]].emplace_back(v[i]);
e[v[i]].emplace_back(u[i]);
}
function<void(int, int)>dfs;
int time_dfs = 0;
dfs = [&] (int s, int p){
if(~h[s] & 1){
label[s] = time_dfs++;
}
for(int& d : e[s]){
if(d != p){
h[d] = h[s] + 1;
dfs(d, s);
}
}
if(h[s] & 1){
label[s] = time_dfs++;
}
};
dfs(h[0] = 0, -1);
return label;
}
int find_next_station(int s, int t, vector<int>c) {
if(c.size() == 1){
return c[0];
}
auto it = lower_bound(c.begin(), c.end(), t);
if(it != c.end() && *it == t){
return t;
}
if(s < c[0]){
return s < t && c[int(c.size()) - 2] > t ? *it : c.back();
}
return t < s && t > c[0] ? *prev(it) : c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
318 ms |
936 KB |
Output is correct |
2 |
Correct |
279 ms |
944 KB |
Output is correct |
3 |
Correct |
554 ms |
684 KB |
Output is correct |
4 |
Correct |
419 ms |
684 KB |
Output is correct |
5 |
Correct |
424 ms |
684 KB |
Output is correct |
6 |
Correct |
308 ms |
924 KB |
Output is correct |
7 |
Correct |
284 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
856 KB |
Output is correct |
2 |
Correct |
332 ms |
1044 KB |
Output is correct |
3 |
Correct |
585 ms |
684 KB |
Output is correct |
4 |
Correct |
481 ms |
684 KB |
Output is correct |
5 |
Correct |
394 ms |
1136 KB |
Output is correct |
6 |
Correct |
286 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
345 ms |
944 KB |
Output is correct |
2 |
Correct |
297 ms |
944 KB |
Output is correct |
3 |
Correct |
555 ms |
856 KB |
Output is correct |
4 |
Correct |
407 ms |
684 KB |
Output is correct |
5 |
Correct |
384 ms |
684 KB |
Output is correct |
6 |
Correct |
266 ms |
924 KB |
Output is correct |
7 |
Correct |
307 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
369 ms |
936 KB |
Output is correct |
12 |
Correct |
278 ms |
1124 KB |
Output is correct |
13 |
Correct |
318 ms |
1032 KB |
Output is correct |
14 |
Correct |
340 ms |
684 KB |
Output is correct |
15 |
Correct |
34 ms |
768 KB |
Output is correct |
16 |
Correct |
36 ms |
888 KB |
Output is correct |
17 |
Correct |
57 ms |
1120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
579 ms |
844 KB |
Output is correct |
2 |
Correct |
480 ms |
684 KB |
Output is correct |
3 |
Correct |
391 ms |
684 KB |
Output is correct |
4 |
Correct |
2 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
371 ms |
680 KB |
Output is correct |
8 |
Correct |
592 ms |
684 KB |
Output is correct |
9 |
Correct |
416 ms |
684 KB |
Output is correct |
10 |
Correct |
394 ms |
684 KB |
Output is correct |
11 |
Correct |
2 ms |
760 KB |
Output is correct |
12 |
Correct |
4 ms |
768 KB |
Output is correct |
13 |
Correct |
4 ms |
860 KB |
Output is correct |
14 |
Correct |
1 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
764 KB |
Output is correct |
16 |
Correct |
315 ms |
684 KB |
Output is correct |
17 |
Correct |
333 ms |
688 KB |
Output is correct |
18 |
Correct |
340 ms |
684 KB |
Output is correct |
19 |
Correct |
328 ms |
936 KB |
Output is correct |
20 |
Correct |
332 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
351 ms |
936 KB |
Output is correct |
2 |
Correct |
283 ms |
928 KB |
Output is correct |
3 |
Correct |
526 ms |
680 KB |
Output is correct |
4 |
Correct |
421 ms |
688 KB |
Output is correct |
5 |
Correct |
357 ms |
684 KB |
Output is correct |
6 |
Correct |
288 ms |
948 KB |
Output is correct |
7 |
Correct |
255 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 |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
297 ms |
856 KB |
Output is correct |
12 |
Correct |
341 ms |
836 KB |
Output is correct |
13 |
Correct |
502 ms |
684 KB |
Output is correct |
14 |
Correct |
402 ms |
764 KB |
Output is correct |
15 |
Correct |
340 ms |
684 KB |
Output is correct |
16 |
Correct |
289 ms |
772 KB |
Output is correct |
17 |
Correct |
381 ms |
684 KB |
Output is correct |
18 |
Correct |
275 ms |
1164 KB |
Output is correct |
19 |
Correct |
303 ms |
1444 KB |
Output is correct |
20 |
Correct |
291 ms |
880 KB |
Output is correct |
21 |
Correct |
40 ms |
768 KB |
Output is correct |
22 |
Correct |
41 ms |
824 KB |
Output is correct |
23 |
Correct |
70 ms |
1116 KB |
Output is correct |
24 |
Correct |
3 ms |
768 KB |
Output is correct |
25 |
Correct |
4 ms |
916 KB |
Output is correct |
26 |
Correct |
4 ms |
768 KB |
Output is correct |
27 |
Correct |
1 ms |
768 KB |
Output is correct |
28 |
Correct |
2 ms |
764 KB |
Output is correct |
29 |
Correct |
317 ms |
684 KB |
Output is correct |
30 |
Correct |
339 ms |
688 KB |
Output is correct |
31 |
Correct |
361 ms |
684 KB |
Output is correct |
32 |
Correct |
327 ms |
684 KB |
Output is correct |
33 |
Correct |
301 ms |
684 KB |
Output is correct |
34 |
Correct |
201 ms |
908 KB |
Output is correct |
35 |
Correct |
274 ms |
984 KB |
Output is correct |
36 |
Correct |
299 ms |
1012 KB |
Output is correct |
37 |
Correct |
310 ms |
968 KB |
Output is correct |
38 |
Correct |
305 ms |
960 KB |
Output is correct |
39 |
Correct |
273 ms |
968 KB |
Output is correct |
40 |
Correct |
301 ms |
980 KB |
Output is correct |
41 |
Correct |
293 ms |
1136 KB |
Output is correct |
42 |
Correct |
30 ms |
920 KB |
Output is correct |
43 |
Correct |
67 ms |
936 KB |
Output is correct |
44 |
Correct |
68 ms |
852 KB |
Output is correct |
45 |
Correct |
94 ms |
920 KB |
Output is correct |
46 |
Correct |
202 ms |
860 KB |
Output is correct |
47 |
Correct |
189 ms |
892 KB |
Output is correct |
48 |
Correct |
35 ms |
1156 KB |
Output is correct |
49 |
Correct |
31 ms |
1768 KB |
Output is correct |