#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
vector<vector<int>> adj(n);
for (int i = 0; i < n - 1; ++i) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
vector<int> in(n), out(n);
int dtime = 0;
auto dfs = [&](auto self, int u, int p, int d) -> void {
if (d == 0) labels[u] = dtime++;
for (int v : adj[u]) if (v != p)
self(self, v, u, d ^ 1);
if (d == 1) labels[u] = dtime++;
};
dfs(dfs, 0, -1, 0);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (s <= c[0]) {
int r = s;
if (s == 0) r = c.back();
else if (c.size() > 1) r = c.end()[-2];
if (s <= t && t <= r)
return *lower_bound(c.begin(), c.end(), t);
return c.back();
}
int l = c[0] + 1;
if (l <= t && t <= s)
return *--upper_bound(c.begin(), c.end(), t);
return c[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
684 KB |
Output is correct |
2 |
Correct |
288 ms |
684 KB |
Output is correct |
3 |
Correct |
613 ms |
684 KB |
Output is correct |
4 |
Correct |
497 ms |
684 KB |
Output is correct |
5 |
Correct |
429 ms |
684 KB |
Output is correct |
6 |
Correct |
307 ms |
684 KB |
Output is correct |
7 |
Correct |
316 ms |
688 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
287 ms |
684 KB |
Output is correct |
2 |
Correct |
339 ms |
684 KB |
Output is correct |
3 |
Correct |
645 ms |
684 KB |
Output is correct |
4 |
Correct |
504 ms |
684 KB |
Output is correct |
5 |
Correct |
399 ms |
684 KB |
Output is correct |
6 |
Correct |
286 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
385 ms |
684 KB |
Output is correct |
2 |
Correct |
303 ms |
684 KB |
Output is correct |
3 |
Correct |
632 ms |
684 KB |
Output is correct |
4 |
Correct |
499 ms |
684 KB |
Output is correct |
5 |
Correct |
429 ms |
684 KB |
Output is correct |
6 |
Correct |
335 ms |
684 KB |
Output is correct |
7 |
Correct |
331 ms |
688 KB |
Output is correct |
8 |
Correct |
1 ms |
772 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
776 KB |
Output is correct |
11 |
Correct |
440 ms |
684 KB |
Output is correct |
12 |
Correct |
371 ms |
1020 KB |
Output is correct |
13 |
Correct |
333 ms |
684 KB |
Output is correct |
14 |
Correct |
302 ms |
684 KB |
Output is correct |
15 |
Correct |
31 ms |
768 KB |
Output is correct |
16 |
Correct |
31 ms |
768 KB |
Output is correct |
17 |
Correct |
69 ms |
776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
663 ms |
684 KB |
Output is correct |
2 |
Correct |
479 ms |
684 KB |
Output is correct |
3 |
Correct |
427 ms |
712 KB |
Output is correct |
4 |
Correct |
2 ms |
764 KB |
Output is correct |
5 |
Correct |
2 ms |
772 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
404 ms |
684 KB |
Output is correct |
8 |
Correct |
636 ms |
684 KB |
Output is correct |
9 |
Correct |
468 ms |
684 KB |
Output is correct |
10 |
Correct |
429 ms |
684 KB |
Output is correct |
11 |
Correct |
3 ms |
764 KB |
Output is correct |
12 |
Correct |
3 ms |
764 KB |
Output is correct |
13 |
Correct |
3 ms |
768 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
764 KB |
Output is correct |
16 |
Correct |
380 ms |
684 KB |
Output is correct |
17 |
Correct |
366 ms |
684 KB |
Output is correct |
18 |
Correct |
383 ms |
684 KB |
Output is correct |
19 |
Correct |
393 ms |
684 KB |
Output is correct |
20 |
Correct |
338 ms |
684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
397 ms |
684 KB |
Output is correct |
2 |
Correct |
290 ms |
684 KB |
Output is correct |
3 |
Correct |
624 ms |
684 KB |
Output is correct |
4 |
Correct |
472 ms |
684 KB |
Output is correct |
5 |
Correct |
382 ms |
684 KB |
Output is correct |
6 |
Correct |
310 ms |
684 KB |
Output is correct |
7 |
Correct |
307 ms |
684 KB |
Output is correct |
8 |
Correct |
2 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
764 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
313 ms |
684 KB |
Output is correct |
12 |
Correct |
389 ms |
684 KB |
Output is correct |
13 |
Correct |
610 ms |
684 KB |
Output is correct |
14 |
Correct |
510 ms |
684 KB |
Output is correct |
15 |
Correct |
417 ms |
684 KB |
Output is correct |
16 |
Correct |
302 ms |
684 KB |
Output is correct |
17 |
Correct |
402 ms |
684 KB |
Output is correct |
18 |
Correct |
297 ms |
1276 KB |
Output is correct |
19 |
Correct |
332 ms |
764 KB |
Output is correct |
20 |
Correct |
274 ms |
684 KB |
Output is correct |
21 |
Correct |
34 ms |
768 KB |
Output is correct |
22 |
Correct |
34 ms |
768 KB |
Output is correct |
23 |
Correct |
58 ms |
744 KB |
Output is correct |
24 |
Correct |
2 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
764 KB |
Output is correct |
26 |
Correct |
2 ms |
780 KB |
Output is correct |
27 |
Correct |
1 ms |
768 KB |
Output is correct |
28 |
Correct |
1 ms |
812 KB |
Output is correct |
29 |
Correct |
326 ms |
684 KB |
Output is correct |
30 |
Correct |
344 ms |
684 KB |
Output is correct |
31 |
Correct |
345 ms |
684 KB |
Output is correct |
32 |
Correct |
348 ms |
684 KB |
Output is correct |
33 |
Correct |
355 ms |
684 KB |
Output is correct |
34 |
Correct |
218 ms |
684 KB |
Output is correct |
35 |
Correct |
296 ms |
684 KB |
Output is correct |
36 |
Correct |
306 ms |
764 KB |
Output is correct |
37 |
Correct |
319 ms |
936 KB |
Output is correct |
38 |
Correct |
285 ms |
764 KB |
Output is correct |
39 |
Correct |
311 ms |
768 KB |
Output is correct |
40 |
Correct |
320 ms |
684 KB |
Output is correct |
41 |
Correct |
323 ms |
772 KB |
Output is correct |
42 |
Correct |
33 ms |
732 KB |
Output is correct |
43 |
Correct |
61 ms |
700 KB |
Output is correct |
44 |
Correct |
81 ms |
716 KB |
Output is correct |
45 |
Correct |
120 ms |
932 KB |
Output is correct |
46 |
Correct |
208 ms |
684 KB |
Output is correct |
47 |
Correct |
222 ms |
684 KB |
Output is correct |
48 |
Correct |
32 ms |
844 KB |
Output is correct |
49 |
Correct |
40 ms |
828 KB |
Output is correct |