#include<bits/stdc++.h>
using namespace std;
int timer;
vector<bool> f;
vector<int> l, d;
vector<vector<int> > g;
void dfs(int id, bool flag = 1){
d[id] = timer++;
f[id] = flag;
for(int v : g[id]) if(d[v] == -1) dfs(v, !flag);
l[id] = timer++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
f.resize(n);
l.assign(n, -1);
d.assign(n, -1);
g.assign(n, {});
for(int i = 0; i < n - 1; i++){
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
timer = 0;
dfs(0);
vector<int> ret(n);
for(int i = 0; i < n; i++){
ret[i] = (f[i] ? d[i] / 2 : l[i] / 2);
}
}
int find_next_station(int s, int t, vector<int> c){
if(s < c[0]){
//c has leaving times
if(s < c.front() || s > c.back()) return c.back();
return c[(int)(lower_bound(c.begin(), c.end(), t) - c.begin())];
}
else{
//c has discovery times
if(s < c.front() || s > c.back()) return c.front();
return c[(int)(upper_bound(c.begin(), c.end(), t) - c.begin()) - 1];
}
}
Compilation message
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
31 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |