#include "stations.h"
#include <vector>
std::vector<int> to[1005];
std::vector<int> dfn;
int t;
void dfs(int x,int f,int dp){
if(!dp)dfn[x]=++t;
for(auto i:to[x])if(i!=f)dfs(i,x,dp^1);
if(dp)dfn[x]=++t;
}
std::vector<int> label(int n, int, std::vector<int> u, std::vector<int> v) {
t=-1;
for (int i = 0; i < n; i++) {
to[i].clear();
}
dfn.resize(n);
for(int i=0;i<n-1;++i)to[u[i]].emplace_back(v[i]),to[v[i]].emplace_back(u[i]);
dfs(0,-1,0);
return dfn;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size()==1)return c[0];
int m=c.size()-1;
if(s==0){
for(auto i:c)if(t<=i)return i;
}
if(c[0]>s){
if(t>s)for(int i=0;i<m;++i)if(t<=c[i])return c[i];
return c[m];
}
else{
if(t<s)for(int i=m;i;--i)if(t>=c[i])return c[i];
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
555 ms |
1024 KB |
Output is correct |
2 |
Correct |
472 ms |
1024 KB |
Output is correct |
3 |
Correct |
854 ms |
996 KB |
Output is correct |
4 |
Correct |
652 ms |
896 KB |
Output is correct |
5 |
Correct |
698 ms |
768 KB |
Output is correct |
6 |
Correct |
600 ms |
1024 KB |
Output is correct |
7 |
Correct |
544 ms |
784 KB |
Output is correct |
8 |
Correct |
3 ms |
776 KB |
Output is correct |
9 |
Correct |
5 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
475 ms |
828 KB |
Output is correct |
2 |
Correct |
570 ms |
840 KB |
Output is correct |
3 |
Correct |
881 ms |
768 KB |
Output is correct |
4 |
Correct |
708 ms |
760 KB |
Output is correct |
5 |
Correct |
730 ms |
888 KB |
Output is correct |
6 |
Correct |
432 ms |
964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
540 ms |
1024 KB |
Output is correct |
2 |
Correct |
460 ms |
1024 KB |
Output is correct |
3 |
Correct |
980 ms |
768 KB |
Output is correct |
4 |
Correct |
695 ms |
640 KB |
Output is correct |
5 |
Correct |
659 ms |
888 KB |
Output is correct |
6 |
Correct |
450 ms |
1024 KB |
Output is correct |
7 |
Correct |
537 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
768 KB |
Output is correct |
9 |
Correct |
3 ms |
892 KB |
Output is correct |
10 |
Correct |
1 ms |
888 KB |
Output is correct |
11 |
Correct |
569 ms |
892 KB |
Output is correct |
12 |
Correct |
522 ms |
1024 KB |
Output is correct |
13 |
Correct |
486 ms |
1124 KB |
Output is correct |
14 |
Correct |
463 ms |
832 KB |
Output is correct |
15 |
Correct |
54 ms |
880 KB |
Output is correct |
16 |
Correct |
65 ms |
1104 KB |
Output is correct |
17 |
Correct |
115 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1005 ms |
768 KB |
Output is correct |
2 |
Correct |
709 ms |
892 KB |
Output is correct |
3 |
Correct |
612 ms |
768 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
631 ms |
884 KB |
Output is correct |
8 |
Correct |
876 ms |
768 KB |
Output is correct |
9 |
Correct |
721 ms |
896 KB |
Output is correct |
10 |
Correct |
627 ms |
768 KB |
Output is correct |
11 |
Correct |
7 ms |
888 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
6 ms |
896 KB |
Output is correct |
14 |
Correct |
4 ms |
892 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
559 ms |
896 KB |
Output is correct |
17 |
Correct |
526 ms |
640 KB |
Output is correct |
18 |
Correct |
549 ms |
768 KB |
Output is correct |
19 |
Correct |
525 ms |
896 KB |
Output is correct |
20 |
Correct |
638 ms |
884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
523 ms |
1024 KB |
Output is correct |
2 |
Correct |
517 ms |
1032 KB |
Output is correct |
3 |
Correct |
919 ms |
892 KB |
Output is correct |
4 |
Correct |
684 ms |
892 KB |
Output is correct |
5 |
Correct |
812 ms |
892 KB |
Output is correct |
6 |
Correct |
461 ms |
1024 KB |
Output is correct |
7 |
Correct |
460 ms |
768 KB |
Output is correct |
8 |
Correct |
2 ms |
768 KB |
Output is correct |
9 |
Correct |
5 ms |
1020 KB |
Output is correct |
10 |
Correct |
1 ms |
888 KB |
Output is correct |
11 |
Correct |
518 ms |
832 KB |
Output is correct |
12 |
Correct |
652 ms |
848 KB |
Output is correct |
13 |
Correct |
914 ms |
1020 KB |
Output is correct |
14 |
Correct |
907 ms |
892 KB |
Output is correct |
15 |
Correct |
664 ms |
768 KB |
Output is correct |
16 |
Correct |
515 ms |
836 KB |
Output is correct |
17 |
Correct |
653 ms |
760 KB |
Output is correct |
18 |
Correct |
531 ms |
868 KB |
Output is correct |
19 |
Correct |
500 ms |
1024 KB |
Output is correct |
20 |
Correct |
446 ms |
836 KB |
Output is correct |
21 |
Correct |
74 ms |
892 KB |
Output is correct |
22 |
Correct |
83 ms |
848 KB |
Output is correct |
23 |
Correct |
120 ms |
780 KB |
Output is correct |
24 |
Correct |
7 ms |
896 KB |
Output is correct |
25 |
Correct |
8 ms |
900 KB |
Output is correct |
26 |
Correct |
5 ms |
912 KB |
Output is correct |
27 |
Correct |
3 ms |
892 KB |
Output is correct |
28 |
Correct |
2 ms |
880 KB |
Output is correct |
29 |
Correct |
505 ms |
892 KB |
Output is correct |
30 |
Correct |
536 ms |
896 KB |
Output is correct |
31 |
Correct |
715 ms |
888 KB |
Output is correct |
32 |
Correct |
491 ms |
768 KB |
Output is correct |
33 |
Correct |
466 ms |
816 KB |
Output is correct |
34 |
Correct |
351 ms |
1024 KB |
Output is correct |
35 |
Correct |
405 ms |
1024 KB |
Output is correct |
36 |
Correct |
474 ms |
1024 KB |
Output is correct |
37 |
Correct |
519 ms |
888 KB |
Output is correct |
38 |
Correct |
455 ms |
868 KB |
Output is correct |
39 |
Correct |
533 ms |
768 KB |
Output is correct |
40 |
Correct |
542 ms |
856 KB |
Output is correct |
41 |
Correct |
449 ms |
768 KB |
Output is correct |
42 |
Correct |
70 ms |
976 KB |
Output is correct |
43 |
Correct |
109 ms |
768 KB |
Output is correct |
44 |
Correct |
138 ms |
960 KB |
Output is correct |
45 |
Correct |
193 ms |
800 KB |
Output is correct |
46 |
Correct |
377 ms |
768 KB |
Output is correct |
47 |
Correct |
393 ms |
796 KB |
Output is correct |
48 |
Correct |
63 ms |
780 KB |
Output is correct |
49 |
Correct |
61 ms |
772 KB |
Output is correct |