#include <bits/stdc++.h>
#include "stations.h"
//~ #include "stub.cpp"
using namespace std;
const int N = 1001;
int st[N], en[N], dep[N], dfstime;
vector <int> g[N];
void dfs(int node, int pnode){
if(dep[node] % 2) st[node] = dfstime++;
for(auto &i : g[node]){
if(i == pnode) continue;
dep[i] = dep[node] + 1;
dfs(i, node);
}
if(dep[node] % 2 == 0) en[node] = dfstime++;
}
vector<int> label(int n, int k, vector<int> u, std::vector<int> v) {
dfstime = 0;
for(int i = 0 ; i < n ; i++){
g[i].clear();
}
for(int i = 0 ; i < (int)u.size() ; i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs(0, -1);
vector <int> ret(n);
for(int i = 0 ; i < n ; i++){
if(dep[i] % 2) ret[i] = st[i];
else ret[i] = en[i];
}
return ret;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size() == 1) return c[0];
if(c.back() > s){
int p = c.back();
c.pop_back();
c.insert(c.begin(), s);
for(int i = 0 ; i + 1 < (int)c.size() ; i++){
if(c[i] <= t && t <= c[i + 1]){
return c[i + 1];
}
}
return p;
}
else{
int p = c[0];
c.erase(c.begin());
c.push_back(s);
for(int i = 0 ; i + 1 < (int)c.size() ; i++){
if(c[i] <= t && t < c[i + 1]){
return c[i];
}
}
return p;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
561 ms |
1212 KB |
Output is correct |
2 |
Correct |
514 ms |
1080 KB |
Output is correct |
3 |
Correct |
944 ms |
864 KB |
Output is correct |
4 |
Correct |
881 ms |
1076 KB |
Output is correct |
5 |
Correct |
696 ms |
1108 KB |
Output is correct |
6 |
Correct |
546 ms |
1088 KB |
Output is correct |
7 |
Correct |
551 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
948 KB |
Output is correct |
9 |
Correct |
5 ms |
736 KB |
Output is correct |
10 |
Correct |
2 ms |
864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
422 ms |
864 KB |
Output is correct |
2 |
Correct |
566 ms |
736 KB |
Output is correct |
3 |
Correct |
1013 ms |
1108 KB |
Output is correct |
4 |
Correct |
722 ms |
948 KB |
Output is correct |
5 |
Correct |
761 ms |
736 KB |
Output is correct |
6 |
Correct |
483 ms |
900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
579 ms |
864 KB |
Output is correct |
2 |
Correct |
468 ms |
1216 KB |
Output is correct |
3 |
Correct |
868 ms |
940 KB |
Output is correct |
4 |
Correct |
727 ms |
864 KB |
Output is correct |
5 |
Correct |
655 ms |
940 KB |
Output is correct |
6 |
Correct |
514 ms |
992 KB |
Output is correct |
7 |
Correct |
542 ms |
992 KB |
Output is correct |
8 |
Correct |
3 ms |
940 KB |
Output is correct |
9 |
Correct |
4 ms |
864 KB |
Output is correct |
10 |
Correct |
1 ms |
948 KB |
Output is correct |
11 |
Correct |
730 ms |
736 KB |
Output is correct |
12 |
Correct |
487 ms |
992 KB |
Output is correct |
13 |
Correct |
507 ms |
1084 KB |
Output is correct |
14 |
Correct |
456 ms |
892 KB |
Output is correct |
15 |
Correct |
49 ms |
1068 KB |
Output is correct |
16 |
Correct |
84 ms |
864 KB |
Output is correct |
17 |
Correct |
102 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
805 ms |
1012 KB |
Output is correct |
2 |
Correct |
856 ms |
1068 KB |
Output is correct |
3 |
Correct |
604 ms |
1108 KB |
Output is correct |
4 |
Correct |
3 ms |
1120 KB |
Output is correct |
5 |
Correct |
5 ms |
864 KB |
Output is correct |
6 |
Correct |
2 ms |
948 KB |
Output is correct |
7 |
Correct |
606 ms |
1068 KB |
Output is correct |
8 |
Correct |
981 ms |
992 KB |
Output is correct |
9 |
Correct |
609 ms |
940 KB |
Output is correct |
10 |
Correct |
601 ms |
948 KB |
Output is correct |
11 |
Correct |
6 ms |
864 KB |
Output is correct |
12 |
Correct |
6 ms |
864 KB |
Output is correct |
13 |
Correct |
4 ms |
864 KB |
Output is correct |
14 |
Correct |
4 ms |
948 KB |
Output is correct |
15 |
Correct |
2 ms |
864 KB |
Output is correct |
16 |
Correct |
576 ms |
1012 KB |
Output is correct |
17 |
Correct |
661 ms |
940 KB |
Output is correct |
18 |
Correct |
686 ms |
940 KB |
Output is correct |
19 |
Correct |
529 ms |
940 KB |
Output is correct |
20 |
Correct |
599 ms |
736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
604 ms |
1084 KB |
Output is correct |
2 |
Correct |
455 ms |
1084 KB |
Output is correct |
3 |
Correct |
899 ms |
940 KB |
Output is correct |
4 |
Correct |
752 ms |
992 KB |
Output is correct |
5 |
Correct |
694 ms |
1108 KB |
Output is correct |
6 |
Correct |
555 ms |
1212 KB |
Output is correct |
7 |
Correct |
570 ms |
864 KB |
Output is correct |
8 |
Correct |
3 ms |
940 KB |
Output is correct |
9 |
Correct |
4 ms |
940 KB |
Output is correct |
10 |
Correct |
2 ms |
736 KB |
Output is correct |
11 |
Correct |
471 ms |
736 KB |
Output is correct |
12 |
Correct |
658 ms |
884 KB |
Output is correct |
13 |
Correct |
1020 ms |
992 KB |
Output is correct |
14 |
Correct |
753 ms |
940 KB |
Output is correct |
15 |
Correct |
638 ms |
940 KB |
Output is correct |
16 |
Correct |
598 ms |
700 KB |
Output is correct |
17 |
Correct |
770 ms |
940 KB |
Output is correct |
18 |
Correct |
593 ms |
1236 KB |
Output is correct |
19 |
Correct |
558 ms |
1212 KB |
Output is correct |
20 |
Correct |
478 ms |
736 KB |
Output is correct |
21 |
Correct |
57 ms |
920 KB |
Output is correct |
22 |
Correct |
72 ms |
864 KB |
Output is correct |
23 |
Correct |
102 ms |
876 KB |
Output is correct |
24 |
Correct |
6 ms |
864 KB |
Output is correct |
25 |
Correct |
6 ms |
940 KB |
Output is correct |
26 |
Correct |
6 ms |
864 KB |
Output is correct |
27 |
Correct |
4 ms |
864 KB |
Output is correct |
28 |
Correct |
2 ms |
948 KB |
Output is correct |
29 |
Correct |
637 ms |
736 KB |
Output is correct |
30 |
Correct |
588 ms |
940 KB |
Output is correct |
31 |
Correct |
630 ms |
736 KB |
Output is correct |
32 |
Correct |
631 ms |
940 KB |
Output is correct |
33 |
Correct |
578 ms |
948 KB |
Output is correct |
34 |
Correct |
397 ms |
1096 KB |
Output is correct |
35 |
Correct |
432 ms |
1072 KB |
Output is correct |
36 |
Correct |
532 ms |
992 KB |
Output is correct |
37 |
Correct |
584 ms |
1228 KB |
Output is correct |
38 |
Correct |
543 ms |
1100 KB |
Output is correct |
39 |
Correct |
516 ms |
1348 KB |
Output is correct |
40 |
Correct |
544 ms |
1248 KB |
Output is correct |
41 |
Correct |
492 ms |
1236 KB |
Output is correct |
42 |
Correct |
69 ms |
864 KB |
Output is correct |
43 |
Correct |
131 ms |
884 KB |
Output is correct |
44 |
Correct |
155 ms |
992 KB |
Output is correct |
45 |
Correct |
154 ms |
1116 KB |
Output is correct |
46 |
Correct |
304 ms |
736 KB |
Output is correct |
47 |
Correct |
330 ms |
1244 KB |
Output is correct |
48 |
Correct |
59 ms |
1084 KB |
Output is correct |
49 |
Correct |
72 ms |
864 KB |
Output is correct |