#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int>>& g, vector<int>& tin, int u, int p, int d, int& timer){
if(!d) tin[u] = timer++;
for(int v : g[u]) if(v != p){
dfs(g, tin, v, u, d ^ 1, timer);
}
if(d) tin[u] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
vector<vector<int>> g(n);
for(int i = 0; i < n - 1; i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
vector<int> tin(n);
int timer = 0;
dfs(g, tin, 0, 0, 0, timer);
return tin;
}
int find_next_station(int s, int t, vector<int> c){
int m = c.size(), i;
if(s < c[0]){
for(i = 0; i < m - 1; i++)
if((i == 0 ? s : c[i-1]) < t && c[i] >= t)
break;
}
else{
for(i = m - 1; i > 0; --i)
if((i + 1 == m ? s : c[i+1]) > t && c[i] <= t)
break;
}
return c[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
692 ms |
680 KB |
Output is correct |
2 |
Correct |
603 ms |
604 KB |
Output is correct |
3 |
Correct |
1134 ms |
400 KB |
Output is correct |
4 |
Correct |
738 ms |
400 KB |
Output is correct |
5 |
Correct |
741 ms |
400 KB |
Output is correct |
6 |
Correct |
606 ms |
528 KB |
Output is correct |
7 |
Correct |
534 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
476 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
489 ms |
492 KB |
Output is correct |
2 |
Correct |
625 ms |
528 KB |
Output is correct |
3 |
Correct |
1012 ms |
428 KB |
Output is correct |
4 |
Correct |
747 ms |
492 KB |
Output is correct |
5 |
Correct |
706 ms |
404 KB |
Output is correct |
6 |
Correct |
513 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
649 ms |
608 KB |
Output is correct |
2 |
Correct |
564 ms |
616 KB |
Output is correct |
3 |
Correct |
1011 ms |
400 KB |
Output is correct |
4 |
Correct |
843 ms |
488 KB |
Output is correct |
5 |
Correct |
743 ms |
484 KB |
Output is correct |
6 |
Correct |
553 ms |
528 KB |
Output is correct |
7 |
Correct |
543 ms |
592 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
636 ms |
616 KB |
Output is correct |
12 |
Correct |
490 ms |
604 KB |
Output is correct |
13 |
Correct |
467 ms |
700 KB |
Output is correct |
14 |
Correct |
498 ms |
528 KB |
Output is correct |
15 |
Correct |
61 ms |
400 KB |
Output is correct |
16 |
Correct |
74 ms |
528 KB |
Output is correct |
17 |
Correct |
112 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
971 ms |
400 KB |
Output is correct |
2 |
Correct |
626 ms |
528 KB |
Output is correct |
3 |
Correct |
634 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
4 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
647 ms |
400 KB |
Output is correct |
8 |
Correct |
960 ms |
400 KB |
Output is correct |
9 |
Correct |
730 ms |
400 KB |
Output is correct |
10 |
Correct |
591 ms |
400 KB |
Output is correct |
11 |
Correct |
6 ms |
468 KB |
Output is correct |
12 |
Correct |
4 ms |
468 KB |
Output is correct |
13 |
Correct |
6 ms |
476 KB |
Output is correct |
14 |
Correct |
5 ms |
472 KB |
Output is correct |
15 |
Correct |
2 ms |
480 KB |
Output is correct |
16 |
Correct |
519 ms |
400 KB |
Output is correct |
17 |
Correct |
545 ms |
488 KB |
Output is correct |
18 |
Correct |
517 ms |
492 KB |
Output is correct |
19 |
Correct |
630 ms |
488 KB |
Output is correct |
20 |
Correct |
588 ms |
400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
670 ms |
656 KB |
Output is correct |
2 |
Correct |
526 ms |
620 KB |
Output is correct |
3 |
Correct |
959 ms |
400 KB |
Output is correct |
4 |
Correct |
763 ms |
400 KB |
Output is correct |
5 |
Correct |
674 ms |
400 KB |
Output is correct |
6 |
Correct |
463 ms |
616 KB |
Output is correct |
7 |
Correct |
527 ms |
568 KB |
Output is correct |
8 |
Correct |
2 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
476 KB |
Output is correct |
10 |
Correct |
0 ms |
468 KB |
Output is correct |
11 |
Correct |
516 ms |
528 KB |
Output is correct |
12 |
Correct |
663 ms |
528 KB |
Output is correct |
13 |
Correct |
971 ms |
400 KB |
Output is correct |
14 |
Correct |
698 ms |
400 KB |
Output is correct |
15 |
Correct |
614 ms |
528 KB |
Output is correct |
16 |
Correct |
544 ms |
484 KB |
Output is correct |
17 |
Correct |
685 ms |
612 KB |
Output is correct |
18 |
Correct |
634 ms |
528 KB |
Output is correct |
19 |
Correct |
490 ms |
680 KB |
Output is correct |
20 |
Correct |
497 ms |
484 KB |
Output is correct |
21 |
Correct |
48 ms |
472 KB |
Output is correct |
22 |
Correct |
73 ms |
560 KB |
Output is correct |
23 |
Correct |
97 ms |
528 KB |
Output is correct |
24 |
Correct |
7 ms |
476 KB |
Output is correct |
25 |
Correct |
5 ms |
400 KB |
Output is correct |
26 |
Correct |
5 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
657 ms |
488 KB |
Output is correct |
30 |
Correct |
621 ms |
400 KB |
Output is correct |
31 |
Correct |
664 ms |
508 KB |
Output is correct |
32 |
Correct |
593 ms |
400 KB |
Output is correct |
33 |
Correct |
585 ms |
400 KB |
Output is correct |
34 |
Correct |
359 ms |
520 KB |
Output is correct |
35 |
Correct |
488 ms |
840 KB |
Output is correct |
36 |
Correct |
550 ms |
608 KB |
Output is correct |
37 |
Correct |
524 ms |
608 KB |
Output is correct |
38 |
Correct |
580 ms |
648 KB |
Output is correct |
39 |
Correct |
546 ms |
616 KB |
Output is correct |
40 |
Correct |
556 ms |
600 KB |
Output is correct |
41 |
Correct |
581 ms |
768 KB |
Output is correct |
42 |
Correct |
63 ms |
556 KB |
Output is correct |
43 |
Correct |
98 ms |
528 KB |
Output is correct |
44 |
Correct |
125 ms |
528 KB |
Output is correct |
45 |
Correct |
203 ms |
536 KB |
Output is correct |
46 |
Correct |
349 ms |
528 KB |
Output is correct |
47 |
Correct |
362 ms |
528 KB |
Output is correct |
48 |
Correct |
70 ms |
548 KB |
Output is correct |
49 |
Correct |
72 ms |
612 KB |
Output is correct |