#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1100;
vector<int> adj[mxN];
std::vector<int> labels;
int timer = 0;
void dfs(int s, int p, int pa) {
if(pa^1)
labels[s] = timer++;
for(auto e : adj[s]) {
if(e == p) continue;
dfs(e, s, pa^1);
}
if(pa)
labels[s] = timer++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i = 0; i < n; ++i) {
adj[i].clear();
}
timer = 0;
for(int i = 0; i < n-1; ++i) {
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
labels.resize(n);
dfs(0, -1, 0);
for(auto z : labels)
cerr << z << " ";
cerr << endl;
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
sort(c.begin(), c.end());
if(s < c[0]) {
//in ostali out
for(auto e : c) {
if(t >= s && t <= e)
return e;
}
return c.back();
} else {
//out ostali in
reverse(c.begin(), c.end());
for(auto e : c) {
if(t <= s && t >= e)
return e;
}
return c.back();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
741 ms |
656 KB |
Output is correct |
2 |
Correct |
554 ms |
688 KB |
Output is correct |
3 |
Correct |
832 ms |
496 KB |
Output is correct |
4 |
Correct |
699 ms |
516 KB |
Output is correct |
5 |
Correct |
706 ms |
528 KB |
Output is correct |
6 |
Correct |
516 ms |
636 KB |
Output is correct |
7 |
Correct |
527 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
5 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
471 ms |
572 KB |
Output is correct |
2 |
Correct |
613 ms |
548 KB |
Output is correct |
3 |
Correct |
1083 ms |
512 KB |
Output is correct |
4 |
Correct |
825 ms |
400 KB |
Output is correct |
5 |
Correct |
794 ms |
400 KB |
Output is correct |
6 |
Correct |
640 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
641 ms |
668 KB |
Output is correct |
2 |
Correct |
462 ms |
656 KB |
Output is correct |
3 |
Correct |
932 ms |
412 KB |
Output is correct |
4 |
Correct |
723 ms |
512 KB |
Output is correct |
5 |
Correct |
654 ms |
512 KB |
Output is correct |
6 |
Correct |
471 ms |
644 KB |
Output is correct |
7 |
Correct |
511 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
3 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Correct |
813 ms |
528 KB |
Output is correct |
12 |
Correct |
552 ms |
780 KB |
Output is correct |
13 |
Correct |
570 ms |
880 KB |
Output is correct |
14 |
Correct |
434 ms |
528 KB |
Output is correct |
15 |
Correct |
54 ms |
576 KB |
Output is correct |
16 |
Correct |
83 ms |
600 KB |
Output is correct |
17 |
Correct |
174 ms |
532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
956 ms |
400 KB |
Output is correct |
2 |
Correct |
674 ms |
516 KB |
Output is correct |
3 |
Correct |
717 ms |
400 KB |
Output is correct |
4 |
Correct |
4 ms |
472 KB |
Output is correct |
5 |
Correct |
5 ms |
472 KB |
Output is correct |
6 |
Correct |
2 ms |
476 KB |
Output is correct |
7 |
Correct |
608 ms |
540 KB |
Output is correct |
8 |
Correct |
1008 ms |
552 KB |
Output is correct |
9 |
Correct |
861 ms |
588 KB |
Output is correct |
10 |
Correct |
765 ms |
512 KB |
Output is correct |
11 |
Correct |
5 ms |
488 KB |
Output is correct |
12 |
Correct |
6 ms |
472 KB |
Output is correct |
13 |
Correct |
6 ms |
600 KB |
Output is correct |
14 |
Correct |
6 ms |
476 KB |
Output is correct |
15 |
Correct |
2 ms |
484 KB |
Output is correct |
16 |
Correct |
636 ms |
400 KB |
Output is correct |
17 |
Correct |
618 ms |
520 KB |
Output is correct |
18 |
Correct |
619 ms |
404 KB |
Output is correct |
19 |
Correct |
640 ms |
400 KB |
Output is correct |
20 |
Correct |
583 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
571 ms |
636 KB |
Output is correct |
2 |
Correct |
625 ms |
644 KB |
Output is correct |
3 |
Correct |
1077 ms |
400 KB |
Output is correct |
4 |
Correct |
845 ms |
400 KB |
Output is correct |
5 |
Correct |
628 ms |
404 KB |
Output is correct |
6 |
Correct |
500 ms |
656 KB |
Output is correct |
7 |
Correct |
596 ms |
528 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
4 ms |
476 KB |
Output is correct |
10 |
Correct |
2 ms |
472 KB |
Output is correct |
11 |
Correct |
633 ms |
540 KB |
Output is correct |
12 |
Correct |
607 ms |
520 KB |
Output is correct |
13 |
Correct |
1136 ms |
528 KB |
Output is correct |
14 |
Correct |
820 ms |
528 KB |
Output is correct |
15 |
Correct |
607 ms |
524 KB |
Output is correct |
16 |
Correct |
452 ms |
528 KB |
Output is correct |
17 |
Correct |
666 ms |
400 KB |
Output is correct |
18 |
Correct |
603 ms |
648 KB |
Output is correct |
19 |
Correct |
547 ms |
760 KB |
Output is correct |
20 |
Correct |
540 ms |
528 KB |
Output is correct |
21 |
Correct |
60 ms |
592 KB |
Output is correct |
22 |
Correct |
107 ms |
528 KB |
Output is correct |
23 |
Correct |
141 ms |
660 KB |
Output is correct |
24 |
Correct |
6 ms |
596 KB |
Output is correct |
25 |
Correct |
5 ms |
468 KB |
Output is correct |
26 |
Correct |
5 ms |
464 KB |
Output is correct |
27 |
Correct |
3 ms |
480 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
550 ms |
528 KB |
Output is correct |
30 |
Correct |
555 ms |
544 KB |
Output is correct |
31 |
Correct |
593 ms |
516 KB |
Output is correct |
32 |
Correct |
564 ms |
424 KB |
Output is correct |
33 |
Correct |
597 ms |
400 KB |
Output is correct |
34 |
Correct |
446 ms |
636 KB |
Output is correct |
35 |
Correct |
535 ms |
1012 KB |
Output is correct |
36 |
Correct |
651 ms |
744 KB |
Output is correct |
37 |
Correct |
505 ms |
764 KB |
Output is correct |
38 |
Correct |
511 ms |
696 KB |
Output is correct |
39 |
Correct |
594 ms |
756 KB |
Output is correct |
40 |
Correct |
586 ms |
648 KB |
Output is correct |
41 |
Correct |
488 ms |
640 KB |
Output is correct |
42 |
Correct |
86 ms |
648 KB |
Output is correct |
43 |
Correct |
179 ms |
604 KB |
Output is correct |
44 |
Correct |
211 ms |
728 KB |
Output is correct |
45 |
Correct |
199 ms |
592 KB |
Output is correct |
46 |
Correct |
400 ms |
532 KB |
Output is correct |
47 |
Correct |
375 ms |
632 KB |
Output is correct |
48 |
Correct |
97 ms |
768 KB |
Output is correct |
49 |
Correct |
87 ms |
772 KB |
Output is correct |