#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
void dfs(int v, int par, int level, int &timer, vector<int> &labels, vector<vector<int>> &g) {
if (level % 2 == 0) labels[v] = timer++;
for (int to : g[v]) {
if (to != par) {
dfs(to, v, level + 1, timer, labels, g);
}
}
if (level % 2 != 0) labels[v] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<vector<int>>g(n);
vector<int>labels(n);
int timer = 0;
for (int i = 0; i < n - 1; ++i) {
g[u[i]].emplace_back(v[i]);
g[v[i]].emplace_back(u[i]);
}
dfs(0, 0, 0, timer, labels, g);
return labels;
}
int find_next_station(int s, int t, vector<int> c) {
if (c[0] > s) {
if (t < s) {
return c.back();
} else {
auto itr = lower_bound(c.begin(), c.end(), t);
if (itr == c.end()) --itr;
return (*itr);
}
} else {
if (t > s) {
return c[0];
} else {
auto itr = upper_bound(c.begin(), c.end(), t);
if (itr != c.begin()) --itr;
return (*itr);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
467 ms |
672 KB |
Output is correct |
2 |
Correct |
386 ms |
628 KB |
Output is correct |
3 |
Correct |
856 ms |
500 KB |
Output is correct |
4 |
Correct |
592 ms |
504 KB |
Output is correct |
5 |
Correct |
450 ms |
508 KB |
Output is correct |
6 |
Correct |
426 ms |
656 KB |
Output is correct |
7 |
Correct |
400 ms |
584 KB |
Output is correct |
8 |
Correct |
2 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
379 ms |
504 KB |
Output is correct |
2 |
Correct |
426 ms |
548 KB |
Output is correct |
3 |
Correct |
670 ms |
420 KB |
Output is correct |
4 |
Correct |
563 ms |
420 KB |
Output is correct |
5 |
Correct |
516 ms |
504 KB |
Output is correct |
6 |
Correct |
373 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
502 ms |
684 KB |
Output is correct |
2 |
Correct |
381 ms |
616 KB |
Output is correct |
3 |
Correct |
744 ms |
420 KB |
Output is correct |
4 |
Correct |
535 ms |
512 KB |
Output is correct |
5 |
Correct |
480 ms |
500 KB |
Output is correct |
6 |
Correct |
419 ms |
628 KB |
Output is correct |
7 |
Correct |
393 ms |
636 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
528 KB |
Output is correct |
10 |
Correct |
0 ms |
500 KB |
Output is correct |
11 |
Correct |
487 ms |
544 KB |
Output is correct |
12 |
Correct |
400 ms |
840 KB |
Output is correct |
13 |
Correct |
415 ms |
660 KB |
Output is correct |
14 |
Correct |
384 ms |
504 KB |
Output is correct |
15 |
Correct |
52 ms |
492 KB |
Output is correct |
16 |
Correct |
56 ms |
680 KB |
Output is correct |
17 |
Correct |
84 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
824 ms |
492 KB |
Output is correct |
2 |
Correct |
526 ms |
416 KB |
Output is correct |
3 |
Correct |
475 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
4 ms |
492 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
489 ms |
416 KB |
Output is correct |
8 |
Correct |
731 ms |
416 KB |
Output is correct |
9 |
Correct |
523 ms |
636 KB |
Output is correct |
10 |
Correct |
476 ms |
508 KB |
Output is correct |
11 |
Correct |
5 ms |
496 KB |
Output is correct |
12 |
Correct |
5 ms |
492 KB |
Output is correct |
13 |
Correct |
4 ms |
500 KB |
Output is correct |
14 |
Correct |
4 ms |
500 KB |
Output is correct |
15 |
Correct |
2 ms |
500 KB |
Output is correct |
16 |
Correct |
467 ms |
416 KB |
Output is correct |
17 |
Correct |
395 ms |
500 KB |
Output is correct |
18 |
Correct |
446 ms |
504 KB |
Output is correct |
19 |
Correct |
397 ms |
416 KB |
Output is correct |
20 |
Correct |
459 ms |
416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
428 ms |
676 KB |
Output is correct |
2 |
Correct |
402 ms |
548 KB |
Output is correct |
3 |
Correct |
747 ms |
416 KB |
Output is correct |
4 |
Correct |
513 ms |
500 KB |
Output is correct |
5 |
Correct |
499 ms |
504 KB |
Output is correct |
6 |
Correct |
382 ms |
536 KB |
Output is correct |
7 |
Correct |
387 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
500 KB |
Output is correct |
9 |
Correct |
3 ms |
500 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
375 ms |
504 KB |
Output is correct |
12 |
Correct |
433 ms |
504 KB |
Output is correct |
13 |
Correct |
715 ms |
428 KB |
Output is correct |
14 |
Correct |
527 ms |
420 KB |
Output is correct |
15 |
Correct |
493 ms |
420 KB |
Output is correct |
16 |
Correct |
386 ms |
544 KB |
Output is correct |
17 |
Correct |
495 ms |
420 KB |
Output is correct |
18 |
Correct |
415 ms |
712 KB |
Output is correct |
19 |
Correct |
428 ms |
744 KB |
Output is correct |
20 |
Correct |
387 ms |
504 KB |
Output is correct |
21 |
Correct |
51 ms |
492 KB |
Output is correct |
22 |
Correct |
57 ms |
572 KB |
Output is correct |
23 |
Correct |
104 ms |
544 KB |
Output is correct |
24 |
Correct |
4 ms |
492 KB |
Output is correct |
25 |
Correct |
5 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
492 KB |
Output is correct |
27 |
Correct |
4 ms |
500 KB |
Output is correct |
28 |
Correct |
2 ms |
500 KB |
Output is correct |
29 |
Correct |
404 ms |
416 KB |
Output is correct |
30 |
Correct |
438 ms |
420 KB |
Output is correct |
31 |
Correct |
394 ms |
504 KB |
Output is correct |
32 |
Correct |
443 ms |
504 KB |
Output is correct |
33 |
Correct |
441 ms |
420 KB |
Output is correct |
34 |
Correct |
247 ms |
636 KB |
Output is correct |
35 |
Correct |
342 ms |
840 KB |
Output is correct |
36 |
Correct |
370 ms |
624 KB |
Output is correct |
37 |
Correct |
391 ms |
504 KB |
Output is correct |
38 |
Correct |
418 ms |
632 KB |
Output is correct |
39 |
Correct |
357 ms |
668 KB |
Output is correct |
40 |
Correct |
344 ms |
596 KB |
Output is correct |
41 |
Correct |
356 ms |
588 KB |
Output is correct |
42 |
Correct |
55 ms |
600 KB |
Output is correct |
43 |
Correct |
81 ms |
568 KB |
Output is correct |
44 |
Correct |
112 ms |
544 KB |
Output is correct |
45 |
Correct |
130 ms |
496 KB |
Output is correct |
46 |
Correct |
258 ms |
544 KB |
Output is correct |
47 |
Correct |
239 ms |
632 KB |
Output is correct |
48 |
Correct |
55 ms |
716 KB |
Output is correct |
49 |
Correct |
54 ms |
700 KB |
Output is correct |