#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> gri;
vector<int> ret;
int cn;
void dfs(int x, int p, int d){
if(!(d&1))ret[x] = cn++;
for(auto i : gri[x]){
if(i == p)continue;
dfs(i,x,d+1);
}
if(d&1)ret[x] = cn++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
cn = 0;
gri.assign(n, vector<int>(0));
ret.assign(n,-1);
for(int i = 0; i < n-1; ++i){
gri[u[i]].push_back(v[i]);
gri[v[i]].push_back(u[i]);
}
dfs(0,0,0);
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
int m = c.size();
if(m == 1)return c[0];
for(auto i : c)if(i == t)return i;
if(s < c[0]){
sort(c.begin(),c.end());
if(t < s)return c.back();
for(int i = 0; i < m-1; ++i){
if(c[i] > t)return c[i];
}
return c.back();
}
sort(c.rbegin(),c.rend());
if(s < t)return c.back();
for(int i = 0; i < m-1; ++i){
if(c[i] < t)return c[i];
}
return c.back();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
558 ms |
1024 KB |
Output is correct |
2 |
Correct |
547 ms |
1024 KB |
Output is correct |
3 |
Correct |
917 ms |
900 KB |
Output is correct |
4 |
Correct |
702 ms |
648 KB |
Output is correct |
5 |
Correct |
639 ms |
640 KB |
Output is correct |
6 |
Correct |
528 ms |
1024 KB |
Output is correct |
7 |
Correct |
447 ms |
764 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
3 ms |
644 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
507 ms |
772 KB |
Output is correct |
2 |
Correct |
581 ms |
768 KB |
Output is correct |
3 |
Correct |
1000 ms |
640 KB |
Output is correct |
4 |
Correct |
712 ms |
640 KB |
Output is correct |
5 |
Correct |
679 ms |
644 KB |
Output is correct |
6 |
Correct |
514 ms |
832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
614 ms |
1264 KB |
Output is correct |
2 |
Correct |
505 ms |
1016 KB |
Output is correct |
3 |
Correct |
1081 ms |
644 KB |
Output is correct |
4 |
Correct |
754 ms |
644 KB |
Output is correct |
5 |
Correct |
709 ms |
872 KB |
Output is correct |
6 |
Correct |
487 ms |
1024 KB |
Output is correct |
7 |
Correct |
528 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
640 KB |
Output is correct |
9 |
Correct |
4 ms |
640 KB |
Output is correct |
10 |
Correct |
2 ms |
640 KB |
Output is correct |
11 |
Correct |
643 ms |
640 KB |
Output is correct |
12 |
Correct |
480 ms |
1024 KB |
Output is correct |
13 |
Correct |
640 ms |
1024 KB |
Output is correct |
14 |
Correct |
473 ms |
824 KB |
Output is correct |
15 |
Correct |
67 ms |
900 KB |
Output is correct |
16 |
Correct |
64 ms |
848 KB |
Output is correct |
17 |
Correct |
109 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
884 ms |
640 KB |
Output is correct |
2 |
Correct |
771 ms |
776 KB |
Output is correct |
3 |
Correct |
704 ms |
640 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
1 ms |
656 KB |
Output is correct |
7 |
Correct |
679 ms |
640 KB |
Output is correct |
8 |
Correct |
947 ms |
780 KB |
Output is correct |
9 |
Correct |
881 ms |
644 KB |
Output is correct |
10 |
Correct |
778 ms |
784 KB |
Output is correct |
11 |
Correct |
5 ms |
644 KB |
Output is correct |
12 |
Correct |
3 ms |
640 KB |
Output is correct |
13 |
Correct |
4 ms |
656 KB |
Output is correct |
14 |
Correct |
4 ms |
640 KB |
Output is correct |
15 |
Correct |
2 ms |
640 KB |
Output is correct |
16 |
Correct |
564 ms |
640 KB |
Output is correct |
17 |
Correct |
517 ms |
892 KB |
Output is correct |
18 |
Correct |
497 ms |
780 KB |
Output is correct |
19 |
Correct |
502 ms |
652 KB |
Output is correct |
20 |
Correct |
482 ms |
640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
546 ms |
1024 KB |
Output is correct |
2 |
Correct |
451 ms |
1024 KB |
Output is correct |
3 |
Correct |
1160 ms |
640 KB |
Output is correct |
4 |
Correct |
919 ms |
644 KB |
Output is correct |
5 |
Correct |
650 ms |
640 KB |
Output is correct |
6 |
Correct |
509 ms |
1024 KB |
Output is correct |
7 |
Correct |
559 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
5 ms |
652 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
436 ms |
764 KB |
Output is correct |
12 |
Correct |
570 ms |
768 KB |
Output is correct |
13 |
Correct |
993 ms |
776 KB |
Output is correct |
14 |
Correct |
802 ms |
644 KB |
Output is correct |
15 |
Correct |
825 ms |
640 KB |
Output is correct |
16 |
Correct |
558 ms |
816 KB |
Output is correct |
17 |
Correct |
650 ms |
648 KB |
Output is correct |
18 |
Correct |
529 ms |
1024 KB |
Output is correct |
19 |
Correct |
465 ms |
1008 KB |
Output is correct |
20 |
Correct |
567 ms |
892 KB |
Output is correct |
21 |
Correct |
60 ms |
892 KB |
Output is correct |
22 |
Correct |
93 ms |
768 KB |
Output is correct |
23 |
Correct |
117 ms |
804 KB |
Output is correct |
24 |
Correct |
6 ms |
640 KB |
Output is correct |
25 |
Correct |
5 ms |
648 KB |
Output is correct |
26 |
Correct |
5 ms |
640 KB |
Output is correct |
27 |
Correct |
4 ms |
640 KB |
Output is correct |
28 |
Correct |
2 ms |
896 KB |
Output is correct |
29 |
Correct |
526 ms |
784 KB |
Output is correct |
30 |
Correct |
523 ms |
656 KB |
Output is correct |
31 |
Correct |
528 ms |
648 KB |
Output is correct |
32 |
Correct |
679 ms |
768 KB |
Output is correct |
33 |
Correct |
593 ms |
640 KB |
Output is correct |
34 |
Correct |
335 ms |
1024 KB |
Output is correct |
35 |
Correct |
485 ms |
1024 KB |
Output is correct |
36 |
Correct |
590 ms |
1096 KB |
Output is correct |
37 |
Correct |
545 ms |
1064 KB |
Output is correct |
38 |
Correct |
460 ms |
1132 KB |
Output is correct |
39 |
Correct |
523 ms |
760 KB |
Output is correct |
40 |
Correct |
471 ms |
768 KB |
Output is correct |
41 |
Correct |
473 ms |
848 KB |
Output is correct |
42 |
Correct |
78 ms |
836 KB |
Output is correct |
43 |
Correct |
143 ms |
820 KB |
Output is correct |
44 |
Correct |
143 ms |
792 KB |
Output is correct |
45 |
Correct |
223 ms |
792 KB |
Output is correct |
46 |
Correct |
327 ms |
824 KB |
Output is correct |
47 |
Correct |
383 ms |
796 KB |
Output is correct |
48 |
Correct |
68 ms |
772 KB |
Output is correct |
49 |
Correct |
67 ms |
1024 KB |
Output is correct |