#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "/home/eagle/ioi20/d2/debug.h"
#else
#define debug(...) void(37)
#endif
std::vector<int> label(int N, int k, std::vector<int> U, std::vector<int> V) {
vector<vector<int>> g(N);
for (int i = 0; i < N - 1; ++i) {
g[U[i]].push_back(V[i]);
g[V[i]].push_back(U[i]);
}
debug(g);
vector<int> label(N), d(N, -1);
int t = 0;
function<void(int)> Dfs = [&](int v) {
if (d[v] % 2 == 0) {
label[v] = t++;
}
for (auto u : g[v]) {
if (d[u] == -1) {
d[u] = d[v] + 1;
Dfs(u);
}
}
if (d[v] % 2 == 1) {
label[v] = t++;
}
};
d[0] = 0;
Dfs(0);
return label;
}
int find_next_station(int S, int T, std::vector<int> C) {
debug(S, T, C);
if (S >= C.back()) {
if (T > S || T < C[0]) {
return C[0];
}
return C[int(lower_bound(C.begin(), C.end(), T + 1) - C.begin()) - 1];
} else {
if (T < S || T > C.back()) {
return C.back();
}
return C[int(lower_bound(C.begin(), C.end(), T) - C.begin())];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
378 ms |
656 KB |
Output is correct |
2 |
Correct |
367 ms |
544 KB |
Output is correct |
3 |
Correct |
588 ms |
416 KB |
Output is correct |
4 |
Correct |
407 ms |
416 KB |
Output is correct |
5 |
Correct |
483 ms |
420 KB |
Output is correct |
6 |
Correct |
338 ms |
628 KB |
Output is correct |
7 |
Correct |
291 ms |
632 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
295 ms |
500 KB |
Output is correct |
2 |
Correct |
417 ms |
544 KB |
Output is correct |
3 |
Correct |
651 ms |
416 KB |
Output is correct |
4 |
Correct |
533 ms |
416 KB |
Output is correct |
5 |
Correct |
458 ms |
420 KB |
Output is correct |
6 |
Correct |
414 ms |
500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
413 ms |
544 KB |
Output is correct |
2 |
Correct |
317 ms |
640 KB |
Output is correct |
3 |
Correct |
703 ms |
504 KB |
Output is correct |
4 |
Correct |
456 ms |
496 KB |
Output is correct |
5 |
Correct |
527 ms |
572 KB |
Output is correct |
6 |
Correct |
299 ms |
544 KB |
Output is correct |
7 |
Correct |
317 ms |
632 KB |
Output is correct |
8 |
Correct |
2 ms |
500 KB |
Output is correct |
9 |
Correct |
4 ms |
416 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
405 ms |
500 KB |
Output is correct |
12 |
Correct |
394 ms |
692 KB |
Output is correct |
13 |
Correct |
367 ms |
704 KB |
Output is correct |
14 |
Correct |
360 ms |
488 KB |
Output is correct |
15 |
Correct |
46 ms |
480 KB |
Output is correct |
16 |
Correct |
44 ms |
584 KB |
Output is correct |
17 |
Correct |
93 ms |
644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
806 ms |
416 KB |
Output is correct |
2 |
Correct |
445 ms |
488 KB |
Output is correct |
3 |
Correct |
512 ms |
416 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
3 ms |
500 KB |
Output is correct |
6 |
Correct |
0 ms |
492 KB |
Output is correct |
7 |
Correct |
419 ms |
500 KB |
Output is correct |
8 |
Correct |
703 ms |
416 KB |
Output is correct |
9 |
Correct |
408 ms |
420 KB |
Output is correct |
10 |
Correct |
425 ms |
416 KB |
Output is correct |
11 |
Correct |
3 ms |
500 KB |
Output is correct |
12 |
Correct |
4 ms |
492 KB |
Output is correct |
13 |
Correct |
3 ms |
492 KB |
Output is correct |
14 |
Correct |
1 ms |
492 KB |
Output is correct |
15 |
Correct |
0 ms |
492 KB |
Output is correct |
16 |
Correct |
342 ms |
504 KB |
Output is correct |
17 |
Correct |
343 ms |
416 KB |
Output is correct |
18 |
Correct |
409 ms |
544 KB |
Output is correct |
19 |
Correct |
455 ms |
416 KB |
Output is correct |
20 |
Correct |
370 ms |
420 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
509 ms |
652 KB |
Output is correct |
2 |
Correct |
274 ms |
656 KB |
Output is correct |
3 |
Correct |
620 ms |
420 KB |
Output is correct |
4 |
Correct |
578 ms |
544 KB |
Output is correct |
5 |
Correct |
527 ms |
504 KB |
Output is correct |
6 |
Correct |
374 ms |
676 KB |
Output is correct |
7 |
Correct |
357 ms |
504 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
500 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
11 |
Correct |
446 ms |
544 KB |
Output is correct |
12 |
Correct |
527 ms |
508 KB |
Output is correct |
13 |
Correct |
659 ms |
488 KB |
Output is correct |
14 |
Correct |
629 ms |
504 KB |
Output is correct |
15 |
Correct |
423 ms |
416 KB |
Output is correct |
16 |
Correct |
325 ms |
508 KB |
Output is correct |
17 |
Correct |
498 ms |
564 KB |
Output is correct |
18 |
Correct |
451 ms |
708 KB |
Output is correct |
19 |
Correct |
300 ms |
720 KB |
Output is correct |
20 |
Correct |
350 ms |
508 KB |
Output is correct |
21 |
Correct |
51 ms |
416 KB |
Output is correct |
22 |
Correct |
63 ms |
568 KB |
Output is correct |
23 |
Correct |
100 ms |
572 KB |
Output is correct |
24 |
Correct |
4 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
4 ms |
492 KB |
Output is correct |
27 |
Correct |
5 ms |
500 KB |
Output is correct |
28 |
Correct |
1 ms |
492 KB |
Output is correct |
29 |
Correct |
556 ms |
564 KB |
Output is correct |
30 |
Correct |
287 ms |
504 KB |
Output is correct |
31 |
Correct |
549 ms |
564 KB |
Output is correct |
32 |
Correct |
451 ms |
484 KB |
Output is correct |
33 |
Correct |
358 ms |
416 KB |
Output is correct |
34 |
Correct |
295 ms |
548 KB |
Output is correct |
35 |
Correct |
262 ms |
724 KB |
Output is correct |
36 |
Correct |
284 ms |
704 KB |
Output is correct |
37 |
Correct |
401 ms |
644 KB |
Output is correct |
38 |
Correct |
376 ms |
620 KB |
Output is correct |
39 |
Correct |
342 ms |
628 KB |
Output is correct |
40 |
Correct |
300 ms |
632 KB |
Output is correct |
41 |
Correct |
413 ms |
588 KB |
Output is correct |
42 |
Correct |
49 ms |
532 KB |
Output is correct |
43 |
Correct |
83 ms |
548 KB |
Output is correct |
44 |
Correct |
101 ms |
544 KB |
Output is correct |
45 |
Correct |
153 ms |
508 KB |
Output is correct |
46 |
Correct |
236 ms |
676 KB |
Output is correct |
47 |
Correct |
226 ms |
504 KB |
Output is correct |
48 |
Correct |
54 ms |
620 KB |
Output is correct |
49 |
Correct |
35 ms |
528 KB |
Output is correct |