#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int INF = (int)1e9 + 7;
const int NS = (int)1e3 + 4;
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
vector<int> labels(n);
int label_num = 0, chk[NS];
memset(chk, 0, sizeof(chk));
vector < int > way[NS];
for(int i = 0; i < n - 1; ++i){
way[u[i]].push_back(v[i]);
way[v[i]].push_back(u[i]);
}
function < void(int, int) > dfs = [&](int x, int dep){
chk[x] = 1;
if(dep % 2) labels[x] = label_num++;
for(auto&nxt:way[x]){
if(chk[nxt]) continue;
dfs(nxt, dep + 1);
}
if(dep % 2 == 0) labels[x] = label_num++;
};
dfs(0, 1);
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
if((int)c.size() == 1) return c[0];
if(s < c[0]){
if(t < s || t > c[(int)c.size() - 2]) return c.back();
for(auto&i:c){
if(t <= i) return i;
}
}
else{
if(t < c[1] || t > s) return c.front();
for(int i = (int)c.size() - 1; ; --i){
if(t >= i) return c[i];
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
46 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
599 ms |
1008 KB |
Output is correct |
2 |
Correct |
495 ms |
1024 KB |
Output is correct |
3 |
Correct |
892 ms |
864 KB |
Output is correct |
4 |
Correct |
689 ms |
768 KB |
Output is correct |
5 |
Correct |
691 ms |
768 KB |
Output is correct |
6 |
Correct |
453 ms |
1024 KB |
Output is correct |
7 |
Correct |
453 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
880 KB |
Output is correct |
9 |
Correct |
4 ms |
768 KB |
Output is correct |
10 |
Correct |
2 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
510 ms |
1008 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
685 ms |
1024 KB |
Output is correct |
2 |
Correct |
488 ms |
1132 KB |
Output is correct |
3 |
Correct |
948 ms |
760 KB |
Output is correct |
4 |
Correct |
743 ms |
872 KB |
Output is correct |
5 |
Correct |
682 ms |
876 KB |
Output is correct |
6 |
Correct |
556 ms |
1024 KB |
Output is correct |
7 |
Correct |
463 ms |
888 KB |
Output is correct |
8 |
Correct |
3 ms |
1008 KB |
Output is correct |
9 |
Correct |
5 ms |
876 KB |
Output is correct |
10 |
Correct |
2 ms |
768 KB |
Output is correct |
11 |
Correct |
632 ms |
884 KB |
Output is correct |
12 |
Correct |
463 ms |
1024 KB |
Output is correct |
13 |
Incorrect |
469 ms |
1016 KB |
Wrong query response. |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
888 ms |
756 KB |
Output is correct |
2 |
Correct |
653 ms |
876 KB |
Output is correct |
3 |
Correct |
596 ms |
884 KB |
Output is correct |
4 |
Correct |
3 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
880 KB |
Output is correct |
6 |
Correct |
2 ms |
884 KB |
Output is correct |
7 |
Correct |
615 ms |
760 KB |
Output is correct |
8 |
Correct |
861 ms |
768 KB |
Output is correct |
9 |
Correct |
680 ms |
888 KB |
Output is correct |
10 |
Correct |
603 ms |
884 KB |
Output is correct |
11 |
Incorrect |
5 ms |
896 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
542 ms |
1024 KB |
Output is correct |
2 |
Correct |
450 ms |
1024 KB |
Output is correct |
3 |
Correct |
866 ms |
884 KB |
Output is correct |
4 |
Correct |
646 ms |
888 KB |
Output is correct |
5 |
Correct |
574 ms |
768 KB |
Output is correct |
6 |
Correct |
482 ms |
1008 KB |
Output is correct |
7 |
Correct |
459 ms |
784 KB |
Output is correct |
8 |
Correct |
4 ms |
780 KB |
Output is correct |
9 |
Correct |
5 ms |
884 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Incorrect |
478 ms |
760 KB |
Wrong query response. |
12 |
Halted |
0 ms |
0 KB |
- |