#include "stations.h"
#include <vector>
using namespace std;
vector<int> adj[1005];
vector<int> a;
bool vis[1001];
int timer = 0;
void dfs(int u, int d){
if (d == 0){
a[u] = timer;
timer++;
}
vis[u] = true;
for(auto v:adj[u]){
if (vis[v]) continue;
dfs(v, d^1);
}
if (d == 1){
a[u] = timer;
timer++;
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
timer = 0;
a.clear();
a.resize(n);
for(int i=0;i<n;i++){
adj[i].clear();
vis[i] = false;
}
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);
return a;
}
int find_next_station(int s, int t, vector<int> c) {
if (c[c.size()-1] < s){
int ans = c[0];
for(auto x : c){
if(min(s, x) <= t && t <= max(s, x))ans = x;
}return ans;
}
else {
for (auto x : c)if(min(s, x) <= t && t <= max(s, x))return x;
return c[c.size()-1];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
333 ms |
896 KB |
Output is correct |
2 |
Correct |
306 ms |
904 KB |
Output is correct |
3 |
Correct |
568 ms |
684 KB |
Output is correct |
4 |
Correct |
421 ms |
684 KB |
Output is correct |
5 |
Correct |
359 ms |
684 KB |
Output is correct |
6 |
Correct |
299 ms |
896 KB |
Output is correct |
7 |
Correct |
270 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
764 KB |
Output is correct |
9 |
Correct |
2 ms |
1204 KB |
Output is correct |
10 |
Correct |
0 ms |
772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
284 ms |
1112 KB |
Output is correct |
2 |
Correct |
320 ms |
804 KB |
Output is correct |
3 |
Correct |
580 ms |
684 KB |
Output is correct |
4 |
Correct |
383 ms |
684 KB |
Output is correct |
5 |
Correct |
442 ms |
684 KB |
Output is correct |
6 |
Correct |
288 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
344 ms |
940 KB |
Output is correct |
2 |
Correct |
299 ms |
904 KB |
Output is correct |
3 |
Correct |
547 ms |
684 KB |
Output is correct |
4 |
Correct |
414 ms |
684 KB |
Output is correct |
5 |
Correct |
445 ms |
684 KB |
Output is correct |
6 |
Correct |
265 ms |
880 KB |
Output is correct |
7 |
Correct |
263 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
768 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
360 ms |
688 KB |
Output is correct |
12 |
Correct |
297 ms |
1100 KB |
Output is correct |
13 |
Correct |
287 ms |
1244 KB |
Output is correct |
14 |
Correct |
290 ms |
684 KB |
Output is correct |
15 |
Correct |
37 ms |
764 KB |
Output is correct |
16 |
Correct |
41 ms |
908 KB |
Output is correct |
17 |
Correct |
60 ms |
956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
544 ms |
784 KB |
Output is correct |
2 |
Correct |
418 ms |
940 KB |
Output is correct |
3 |
Correct |
327 ms |
684 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
0 ms |
764 KB |
Output is correct |
7 |
Correct |
412 ms |
940 KB |
Output is correct |
8 |
Correct |
542 ms |
684 KB |
Output is correct |
9 |
Correct |
429 ms |
684 KB |
Output is correct |
10 |
Correct |
395 ms |
684 KB |
Output is correct |
11 |
Correct |
4 ms |
944 KB |
Output is correct |
12 |
Correct |
4 ms |
924 KB |
Output is correct |
13 |
Correct |
3 ms |
764 KB |
Output is correct |
14 |
Correct |
2 ms |
768 KB |
Output is correct |
15 |
Correct |
0 ms |
1012 KB |
Output is correct |
16 |
Correct |
314 ms |
940 KB |
Output is correct |
17 |
Correct |
297 ms |
684 KB |
Output is correct |
18 |
Correct |
299 ms |
684 KB |
Output is correct |
19 |
Correct |
336 ms |
684 KB |
Output is correct |
20 |
Correct |
305 ms |
684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
340 ms |
904 KB |
Output is correct |
2 |
Correct |
302 ms |
956 KB |
Output is correct |
3 |
Correct |
592 ms |
684 KB |
Output is correct |
4 |
Correct |
426 ms |
684 KB |
Output is correct |
5 |
Correct |
404 ms |
684 KB |
Output is correct |
6 |
Correct |
303 ms |
900 KB |
Output is correct |
7 |
Correct |
268 ms |
684 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
2 ms |
1028 KB |
Output is correct |
10 |
Correct |
0 ms |
768 KB |
Output is correct |
11 |
Correct |
306 ms |
856 KB |
Output is correct |
12 |
Correct |
350 ms |
828 KB |
Output is correct |
13 |
Correct |
512 ms |
684 KB |
Output is correct |
14 |
Correct |
433 ms |
940 KB |
Output is correct |
15 |
Correct |
352 ms |
684 KB |
Output is correct |
16 |
Correct |
319 ms |
684 KB |
Output is correct |
17 |
Correct |
345 ms |
684 KB |
Output is correct |
18 |
Correct |
252 ms |
1128 KB |
Output is correct |
19 |
Correct |
298 ms |
1256 KB |
Output is correct |
20 |
Correct |
247 ms |
684 KB |
Output is correct |
21 |
Correct |
30 ms |
684 KB |
Output is correct |
22 |
Correct |
38 ms |
1084 KB |
Output is correct |
23 |
Correct |
52 ms |
904 KB |
Output is correct |
24 |
Correct |
4 ms |
768 KB |
Output is correct |
25 |
Correct |
2 ms |
768 KB |
Output is correct |
26 |
Correct |
3 ms |
768 KB |
Output is correct |
27 |
Correct |
2 ms |
768 KB |
Output is correct |
28 |
Correct |
1 ms |
764 KB |
Output is correct |
29 |
Correct |
348 ms |
684 KB |
Output is correct |
30 |
Correct |
317 ms |
1120 KB |
Output is correct |
31 |
Correct |
318 ms |
684 KB |
Output is correct |
32 |
Correct |
297 ms |
684 KB |
Output is correct |
33 |
Correct |
292 ms |
684 KB |
Output is correct |
34 |
Correct |
215 ms |
896 KB |
Output is correct |
35 |
Correct |
275 ms |
1512 KB |
Output is correct |
36 |
Correct |
283 ms |
992 KB |
Output is correct |
37 |
Correct |
292 ms |
988 KB |
Output is correct |
38 |
Correct |
308 ms |
1224 KB |
Output is correct |
39 |
Correct |
290 ms |
980 KB |
Output is correct |
40 |
Correct |
286 ms |
1132 KB |
Output is correct |
41 |
Correct |
360 ms |
1136 KB |
Output is correct |
42 |
Correct |
33 ms |
1124 KB |
Output is correct |
43 |
Correct |
55 ms |
1116 KB |
Output is correct |
44 |
Correct |
85 ms |
1164 KB |
Output is correct |
45 |
Correct |
101 ms |
968 KB |
Output is correct |
46 |
Correct |
207 ms |
844 KB |
Output is correct |
47 |
Correct |
184 ms |
872 KB |
Output is correct |
48 |
Correct |
38 ms |
1152 KB |
Output is correct |
49 |
Correct |
28 ms |
1276 KB |
Output is correct |