#include "stations.h"
#include <vector>
using namespace std;
typedef vector<int> vi;
const int N = 1000;
void dfs(vector<vi> ej, vi &ta, vi &tb, int p, int i, int d, int &time) {
if (d % 2 == 0)
ta[i] = time++;
for (int j : ej[i])
if (j != p)
dfs(ej, ta, tb, i, j, d + 1, time);
if (d % 2 == 1)
ta[i] = time++;
}
vi label(int n, int k, vi uu, vi vv) {
vector<vi> ej(n);
vi ta(n, 0), tb(n, 0), labels(n, 0);
int h, i, time;
for (h = 0; h < n - 1; h++) {
ej[uu[h]].push_back(vv[h]);
ej[vv[h]].push_back(uu[h]);
}
time = 0, dfs(ej, ta, tb, -1, 0, 0, time);
for (i = 0; i < n; i++)
labels[i] = ta[i];
return labels;
}
int find_next_station(int s, int t, vi cc) {
int m = cc.size(), h;
if (s < cc[0]) {
for (h = 0; h < m - 1; h++)
if ((h == 0 ? s : cc[h - 1]) < t && t <= cc[h])
break;
} else {
for (h = m - 1; h > 0; h--)
if ((h + 1 == m ? s : cc[h + 1]) > t && t >= cc[h])
break;
}
return cc[h];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
859 ms |
55456 KB |
Output is correct |
2 |
Correct |
1093 ms |
55160 KB |
Output is correct |
3 |
Correct |
1031 ms |
648 KB |
Output is correct |
4 |
Correct |
783 ms |
520 KB |
Output is correct |
5 |
Correct |
837 ms |
524 KB |
Output is correct |
6 |
Correct |
1120 ms |
49216 KB |
Output is correct |
7 |
Correct |
647 ms |
41708 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
4 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1135 ms |
1092 KB |
Output is correct |
2 |
Correct |
676 ms |
1116 KB |
Output is correct |
3 |
Correct |
1091 ms |
400 KB |
Output is correct |
4 |
Correct |
689 ms |
400 KB |
Output is correct |
5 |
Correct |
602 ms |
476 KB |
Output is correct |
6 |
Correct |
556 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
830 ms |
55472 KB |
Output is correct |
2 |
Correct |
1096 ms |
53052 KB |
Output is correct |
3 |
Correct |
1077 ms |
452 KB |
Output is correct |
4 |
Correct |
664 ms |
412 KB |
Output is correct |
5 |
Correct |
560 ms |
400 KB |
Output is correct |
6 |
Correct |
1107 ms |
53372 KB |
Output is correct |
7 |
Correct |
601 ms |
42648 KB |
Output is correct |
8 |
Correct |
1 ms |
472 KB |
Output is correct |
9 |
Correct |
3 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
648 ms |
456 KB |
Output is correct |
12 |
Correct |
1034 ms |
54600 KB |
Output is correct |
13 |
Correct |
1149 ms |
50252 KB |
Output is correct |
14 |
Correct |
591 ms |
3112 KB |
Output is correct |
15 |
Correct |
56 ms |
420 KB |
Output is correct |
16 |
Correct |
228 ms |
628 KB |
Output is correct |
17 |
Correct |
608 ms |
688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1053 ms |
480 KB |
Output is correct |
2 |
Correct |
800 ms |
400 KB |
Output is correct |
3 |
Correct |
816 ms |
420 KB |
Output is correct |
4 |
Correct |
3 ms |
468 KB |
Output is correct |
5 |
Correct |
5 ms |
472 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
660 ms |
480 KB |
Output is correct |
8 |
Correct |
1043 ms |
400 KB |
Output is correct |
9 |
Correct |
746 ms |
476 KB |
Output is correct |
10 |
Correct |
712 ms |
400 KB |
Output is correct |
11 |
Correct |
5 ms |
468 KB |
Output is correct |
12 |
Correct |
6 ms |
468 KB |
Output is correct |
13 |
Correct |
5 ms |
468 KB |
Output is correct |
14 |
Correct |
4 ms |
468 KB |
Output is correct |
15 |
Correct |
1 ms |
468 KB |
Output is correct |
16 |
Correct |
606 ms |
404 KB |
Output is correct |
17 |
Correct |
685 ms |
472 KB |
Output is correct |
18 |
Correct |
618 ms |
476 KB |
Output is correct |
19 |
Correct |
601 ms |
400 KB |
Output is correct |
20 |
Correct |
612 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
861 ms |
55492 KB |
Output is correct |
2 |
Correct |
1093 ms |
48760 KB |
Output is correct |
3 |
Correct |
886 ms |
404 KB |
Output is correct |
4 |
Correct |
737 ms |
400 KB |
Output is correct |
5 |
Correct |
745 ms |
476 KB |
Output is correct |
6 |
Correct |
1022 ms |
55532 KB |
Output is correct |
7 |
Correct |
705 ms |
31092 KB |
Output is correct |
8 |
Correct |
3 ms |
468 KB |
Output is correct |
9 |
Correct |
5 ms |
468 KB |
Output is correct |
10 |
Correct |
0 ms |
476 KB |
Output is correct |
11 |
Correct |
1099 ms |
1088 KB |
Output is correct |
12 |
Correct |
742 ms |
1044 KB |
Output is correct |
13 |
Correct |
961 ms |
400 KB |
Output is correct |
14 |
Correct |
779 ms |
528 KB |
Output is correct |
15 |
Correct |
669 ms |
400 KB |
Output is correct |
16 |
Correct |
543 ms |
984 KB |
Output is correct |
17 |
Correct |
804 ms |
476 KB |
Output is correct |
18 |
Correct |
1068 ms |
37388 KB |
Output is correct |
19 |
Correct |
1186 ms |
51588 KB |
Output is correct |
20 |
Correct |
578 ms |
4248 KB |
Output is correct |
21 |
Correct |
62 ms |
400 KB |
Output is correct |
22 |
Correct |
220 ms |
620 KB |
Output is correct |
23 |
Correct |
614 ms |
740 KB |
Output is correct |
24 |
Correct |
6 ms |
444 KB |
Output is correct |
25 |
Correct |
6 ms |
468 KB |
Output is correct |
26 |
Correct |
4 ms |
468 KB |
Output is correct |
27 |
Correct |
4 ms |
476 KB |
Output is correct |
28 |
Correct |
1 ms |
476 KB |
Output is correct |
29 |
Correct |
536 ms |
604 KB |
Output is correct |
30 |
Correct |
569 ms |
404 KB |
Output is correct |
31 |
Correct |
594 ms |
400 KB |
Output is correct |
32 |
Correct |
623 ms |
400 KB |
Output is correct |
33 |
Correct |
603 ms |
400 KB |
Output is correct |
34 |
Correct |
913 ms |
41992 KB |
Output is correct |
35 |
Correct |
1141 ms |
55436 KB |
Output is correct |
36 |
Correct |
1117 ms |
45748 KB |
Output is correct |
37 |
Correct |
1151 ms |
13516 KB |
Output is correct |
38 |
Correct |
1264 ms |
13384 KB |
Output is correct |
39 |
Correct |
1120 ms |
18012 KB |
Output is correct |
40 |
Correct |
1117 ms |
17744 KB |
Output is correct |
41 |
Correct |
1230 ms |
14544 KB |
Output is correct |
42 |
Correct |
339 ms |
664 KB |
Output is correct |
43 |
Correct |
622 ms |
736 KB |
Output is correct |
44 |
Correct |
638 ms |
1064 KB |
Output is correct |
45 |
Correct |
762 ms |
1516 KB |
Output is correct |
46 |
Correct |
745 ms |
13836 KB |
Output is correct |
47 |
Correct |
1036 ms |
26748 KB |
Output is correct |
48 |
Correct |
536 ms |
1168 KB |
Output is correct |
49 |
Correct |
637 ms |
1104 KB |
Output is correct |