#include <bits/stdc++.h>
using namespace std;
int ti; vector<int> ans, adj[1005];
void dfs(int i, int dep, int p){
if (dep % 2 == 0) ans[i] = ti++;
for (int to : adj[i]) if (to != p) dfs(to, dep + 1, i);
if (dep % 2 == 1) ans[i] = ti++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
for (int i = 0; i < n; i++) adj[i].clear();
ti = 0; ans.assign(n, 0);
for (int i = 0; i < n - 1; i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0, 0, -1);
return ans;
}
int find_next_station(int s, int t, vector<int> c){
if (s > c[0]){ //tout layer
if (t < c[0] or t > s) return c[0];
return *prev(upper_bound(c.begin(), c.end(), t));
}
else{ //tin layer
if (t < s or t > c.back()) return c.back();
return *lower_bound(c.begin(), c.end(), t);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
589 ms |
684 KB |
Output is correct |
2 |
Correct |
464 ms |
652 KB |
Output is correct |
3 |
Correct |
856 ms |
416 KB |
Output is correct |
4 |
Correct |
514 ms |
416 KB |
Output is correct |
5 |
Correct |
598 ms |
532 KB |
Output is correct |
6 |
Correct |
443 ms |
660 KB |
Output is correct |
7 |
Correct |
438 ms |
536 KB |
Output is correct |
8 |
Correct |
3 ms |
500 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
507 ms |
572 KB |
Output is correct |
2 |
Correct |
473 ms |
532 KB |
Output is correct |
3 |
Correct |
854 ms |
416 KB |
Output is correct |
4 |
Correct |
576 ms |
672 KB |
Output is correct |
5 |
Correct |
570 ms |
524 KB |
Output is correct |
6 |
Correct |
424 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
465 ms |
672 KB |
Output is correct |
2 |
Correct |
407 ms |
652 KB |
Output is correct |
3 |
Correct |
856 ms |
416 KB |
Output is correct |
4 |
Correct |
652 ms |
420 KB |
Output is correct |
5 |
Correct |
525 ms |
532 KB |
Output is correct |
6 |
Correct |
443 ms |
524 KB |
Output is correct |
7 |
Correct |
449 ms |
600 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
592 KB |
Output is correct |
10 |
Correct |
1 ms |
492 KB |
Output is correct |
11 |
Correct |
627 ms |
420 KB |
Output is correct |
12 |
Correct |
445 ms |
760 KB |
Output is correct |
13 |
Correct |
427 ms |
784 KB |
Output is correct |
14 |
Correct |
470 ms |
536 KB |
Output is correct |
15 |
Correct |
59 ms |
440 KB |
Output is correct |
16 |
Correct |
60 ms |
548 KB |
Output is correct |
17 |
Correct |
98 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
885 ms |
596 KB |
Output is correct |
2 |
Correct |
710 ms |
528 KB |
Output is correct |
3 |
Correct |
554 ms |
420 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
4 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
453 ms |
420 KB |
Output is correct |
8 |
Correct |
938 ms |
416 KB |
Output is correct |
9 |
Correct |
644 ms |
524 KB |
Output is correct |
10 |
Correct |
600 ms |
552 KB |
Output is correct |
11 |
Correct |
5 ms |
492 KB |
Output is correct |
12 |
Correct |
4 ms |
492 KB |
Output is correct |
13 |
Correct |
3 ms |
500 KB |
Output is correct |
14 |
Correct |
3 ms |
492 KB |
Output is correct |
15 |
Correct |
1 ms |
492 KB |
Output is correct |
16 |
Correct |
447 ms |
524 KB |
Output is correct |
17 |
Correct |
497 ms |
528 KB |
Output is correct |
18 |
Correct |
540 ms |
528 KB |
Output is correct |
19 |
Correct |
439 ms |
548 KB |
Output is correct |
20 |
Correct |
536 ms |
540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
533 ms |
656 KB |
Output is correct |
2 |
Correct |
397 ms |
656 KB |
Output is correct |
3 |
Correct |
835 ms |
420 KB |
Output is correct |
4 |
Correct |
669 ms |
416 KB |
Output is correct |
5 |
Correct |
611 ms |
416 KB |
Output is correct |
6 |
Correct |
449 ms |
652 KB |
Output is correct |
7 |
Correct |
491 ms |
544 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
4 ms |
472 KB |
Output is correct |
10 |
Correct |
0 ms |
492 KB |
Output is correct |
11 |
Correct |
392 ms |
516 KB |
Output is correct |
12 |
Correct |
586 ms |
532 KB |
Output is correct |
13 |
Correct |
725 ms |
524 KB |
Output is correct |
14 |
Correct |
647 ms |
416 KB |
Output is correct |
15 |
Correct |
544 ms |
420 KB |
Output is correct |
16 |
Correct |
439 ms |
548 KB |
Output is correct |
17 |
Correct |
470 ms |
416 KB |
Output is correct |
18 |
Correct |
473 ms |
636 KB |
Output is correct |
19 |
Correct |
512 ms |
760 KB |
Output is correct |
20 |
Correct |
400 ms |
532 KB |
Output is correct |
21 |
Correct |
48 ms |
492 KB |
Output is correct |
22 |
Correct |
64 ms |
576 KB |
Output is correct |
23 |
Correct |
117 ms |
544 KB |
Output is correct |
24 |
Correct |
5 ms |
500 KB |
Output is correct |
25 |
Correct |
4 ms |
492 KB |
Output is correct |
26 |
Correct |
3 ms |
500 KB |
Output is correct |
27 |
Correct |
1 ms |
492 KB |
Output is correct |
28 |
Correct |
1 ms |
500 KB |
Output is correct |
29 |
Correct |
514 ms |
540 KB |
Output is correct |
30 |
Correct |
495 ms |
528 KB |
Output is correct |
31 |
Correct |
478 ms |
536 KB |
Output is correct |
32 |
Correct |
430 ms |
528 KB |
Output is correct |
33 |
Correct |
411 ms |
532 KB |
Output is correct |
34 |
Correct |
351 ms |
548 KB |
Output is correct |
35 |
Correct |
453 ms |
672 KB |
Output is correct |
36 |
Correct |
422 ms |
644 KB |
Output is correct |
37 |
Correct |
418 ms |
632 KB |
Output is correct |
38 |
Correct |
421 ms |
628 KB |
Output is correct |
39 |
Correct |
462 ms |
748 KB |
Output is correct |
40 |
Correct |
524 ms |
544 KB |
Output is correct |
41 |
Correct |
475 ms |
632 KB |
Output is correct |
42 |
Correct |
56 ms |
544 KB |
Output is correct |
43 |
Correct |
82 ms |
672 KB |
Output is correct |
44 |
Correct |
140 ms |
624 KB |
Output is correct |
45 |
Correct |
138 ms |
596 KB |
Output is correct |
46 |
Correct |
275 ms |
596 KB |
Output is correct |
47 |
Correct |
255 ms |
616 KB |
Output is correct |
48 |
Correct |
66 ms |
768 KB |
Output is correct |
49 |
Correct |
47 ms |
700 KB |
Output is correct |