#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector <vector<int>> e;
vector<int> labels;
e.resize(n);
int cnt = 0;
auto dfs = [&](auto self, int node, int p, int d) -> void{
if(d == 0)labels[node] = cnt++;
for(auto i:e[node]){
if(i == p)continue;
self(self, i, node, d^1);
}
if(d == 1)labels[node] = cnt++;
};
labels.resize(n);
for(int i = 0;i < n - 1;i++){
e[u[i]].push_back(v[i]);
e[v[i]].push_back(u[i]);
}
for(int i = 0;i < n;i++){
if(e[i].size() == 1){
dfs(dfs, i, -1, 0);
break;
}
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if(c.size() == 1)return c[0];
sort(c.begin(),c.end());
if(s < c[0]){
if(s <= t && t <= c[(int)c.size() - 2]){
int nr = 1000000;
for(auto i:c){
if(t <= i){
nr = min(nr, i);
}
}
return nr;
}else{
return c[(int)c.size() - 1];
}
}else{
if(c[1] <= t && t <= s){
int nr = -1;
for(auto i:c){
if(i <= t){
nr = max(nr, i);
}
}
return nr;
}else{
return c[0];
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
479 ms |
668 KB |
Output is correct |
2 |
Correct |
402 ms |
668 KB |
Output is correct |
3 |
Correct |
836 ms |
668 KB |
Output is correct |
4 |
Correct |
620 ms |
668 KB |
Output is correct |
5 |
Correct |
520 ms |
668 KB |
Output is correct |
6 |
Correct |
428 ms |
668 KB |
Output is correct |
7 |
Correct |
396 ms |
668 KB |
Output is correct |
8 |
Correct |
2 ms |
752 KB |
Output is correct |
9 |
Correct |
3 ms |
936 KB |
Output is correct |
10 |
Correct |
1 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
387 ms |
668 KB |
Output is correct |
2 |
Correct |
495 ms |
668 KB |
Output is correct |
3 |
Correct |
815 ms |
668 KB |
Output is correct |
4 |
Correct |
602 ms |
668 KB |
Output is correct |
5 |
Correct |
544 ms |
668 KB |
Output is correct |
6 |
Correct |
403 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
473 ms |
668 KB |
Output is correct |
2 |
Correct |
398 ms |
668 KB |
Output is correct |
3 |
Correct |
819 ms |
668 KB |
Output is correct |
4 |
Correct |
607 ms |
668 KB |
Output is correct |
5 |
Correct |
535 ms |
668 KB |
Output is correct |
6 |
Correct |
405 ms |
668 KB |
Output is correct |
7 |
Correct |
402 ms |
668 KB |
Output is correct |
8 |
Correct |
3 ms |
764 KB |
Output is correct |
9 |
Correct |
3 ms |
752 KB |
Output is correct |
10 |
Correct |
1 ms |
752 KB |
Output is correct |
11 |
Correct |
523 ms |
668 KB |
Output is correct |
12 |
Correct |
409 ms |
772 KB |
Output is correct |
13 |
Correct |
422 ms |
764 KB |
Output is correct |
14 |
Correct |
422 ms |
668 KB |
Output is correct |
15 |
Correct |
39 ms |
752 KB |
Output is correct |
16 |
Correct |
48 ms |
808 KB |
Output is correct |
17 |
Correct |
82 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
828 ms |
668 KB |
Output is correct |
2 |
Correct |
595 ms |
668 KB |
Output is correct |
3 |
Correct |
527 ms |
668 KB |
Output is correct |
4 |
Correct |
2 ms |
752 KB |
Output is correct |
5 |
Correct |
3 ms |
752 KB |
Output is correct |
6 |
Correct |
2 ms |
752 KB |
Output is correct |
7 |
Correct |
559 ms |
668 KB |
Output is correct |
8 |
Correct |
782 ms |
668 KB |
Output is correct |
9 |
Correct |
617 ms |
836 KB |
Output is correct |
10 |
Correct |
528 ms |
668 KB |
Output is correct |
11 |
Correct |
4 ms |
752 KB |
Output is correct |
12 |
Correct |
4 ms |
920 KB |
Output is correct |
13 |
Correct |
3 ms |
752 KB |
Output is correct |
14 |
Correct |
3 ms |
764 KB |
Output is correct |
15 |
Correct |
2 ms |
752 KB |
Output is correct |
16 |
Correct |
452 ms |
668 KB |
Output is correct |
17 |
Correct |
446 ms |
668 KB |
Output is correct |
18 |
Correct |
443 ms |
668 KB |
Output is correct |
19 |
Correct |
449 ms |
668 KB |
Output is correct |
20 |
Correct |
454 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
490 ms |
668 KB |
Output is correct |
2 |
Correct |
399 ms |
668 KB |
Output is correct |
3 |
Correct |
783 ms |
668 KB |
Output is correct |
4 |
Correct |
621 ms |
668 KB |
Output is correct |
5 |
Correct |
559 ms |
668 KB |
Output is correct |
6 |
Correct |
406 ms |
668 KB |
Output is correct |
7 |
Correct |
386 ms |
668 KB |
Output is correct |
8 |
Correct |
3 ms |
752 KB |
Output is correct |
9 |
Correct |
4 ms |
924 KB |
Output is correct |
10 |
Correct |
2 ms |
752 KB |
Output is correct |
11 |
Correct |
409 ms |
668 KB |
Output is correct |
12 |
Correct |
488 ms |
668 KB |
Output is correct |
13 |
Correct |
783 ms |
668 KB |
Output is correct |
14 |
Correct |
576 ms |
668 KB |
Output is correct |
15 |
Correct |
522 ms |
668 KB |
Output is correct |
16 |
Correct |
398 ms |
668 KB |
Output is correct |
17 |
Correct |
537 ms |
668 KB |
Output is correct |
18 |
Correct |
407 ms |
776 KB |
Output is correct |
19 |
Correct |
408 ms |
920 KB |
Output is correct |
20 |
Correct |
405 ms |
668 KB |
Output is correct |
21 |
Correct |
39 ms |
668 KB |
Output is correct |
22 |
Correct |
64 ms |
752 KB |
Output is correct |
23 |
Correct |
80 ms |
668 KB |
Output is correct |
24 |
Correct |
4 ms |
752 KB |
Output is correct |
25 |
Correct |
4 ms |
752 KB |
Output is correct |
26 |
Correct |
3 ms |
752 KB |
Output is correct |
27 |
Correct |
3 ms |
752 KB |
Output is correct |
28 |
Correct |
2 ms |
756 KB |
Output is correct |
29 |
Correct |
450 ms |
668 KB |
Output is correct |
30 |
Correct |
444 ms |
668 KB |
Output is correct |
31 |
Correct |
459 ms |
668 KB |
Output is correct |
32 |
Correct |
454 ms |
668 KB |
Output is correct |
33 |
Correct |
468 ms |
668 KB |
Output is correct |
34 |
Correct |
274 ms |
668 KB |
Output is correct |
35 |
Correct |
369 ms |
668 KB |
Output is correct |
36 |
Correct |
382 ms |
764 KB |
Output is correct |
37 |
Correct |
412 ms |
916 KB |
Output is correct |
38 |
Correct |
405 ms |
776 KB |
Output is correct |
39 |
Correct |
418 ms |
1024 KB |
Output is correct |
40 |
Correct |
394 ms |
1032 KB |
Output is correct |
41 |
Correct |
412 ms |
1032 KB |
Output is correct |
42 |
Correct |
45 ms |
740 KB |
Output is correct |
43 |
Correct |
97 ms |
668 KB |
Output is correct |
44 |
Correct |
106 ms |
668 KB |
Output is correct |
45 |
Correct |
131 ms |
668 KB |
Output is correct |
46 |
Correct |
275 ms |
684 KB |
Output is correct |
47 |
Correct |
262 ms |
668 KB |
Output is correct |
48 |
Correct |
50 ms |
824 KB |
Output is correct |
49 |
Correct |
48 ms |
752 KB |
Output is correct |