#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll in[1005], out[1005];
vector<ll> T[1005];
ll num = -1;
void dfs(ll u, ll p){
in[u] = ++num;
for(auto v : T[u]){
if(v == p) continue;
dfs(v, u);
}
out[u] = num;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for(int i = 0; i < n - 1; i++){
T[u[i]].push_back(v[i]);
T[v[i]].push_back(u[i]);
}
dfs(0, -1);
vector<int> L(n);
for(int i = 0; i < n; i++){
L[i] = in[i] * 1000 + out[i];
}
return L;
}
bool is_par(ll u, ll v){
return (u / 1000 <= v / 1000 && v % 1000 <= u % 1000);
}
int find_next_station(int s, int t, std::vector<int> c) {
if(is_par(s, t)){
for(auto i : c){
if(is_par(s, i) && is_par(i, t)){
return i;
}
}
} else if(is_par(t, s)){
for(auto i : c){
if(is_par(t, i) && is_par(i, s)){
return i;
}
}
} else {
for(auto i : c){
if(is_par(i, s)){
return i;
}
}
}
}
Compilation message
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
52 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1092 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3050 ms |
480 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1218 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
893 ms |
504 KB |
Output is correct |
2 |
Runtime error |
929 ms |
2097156 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2284 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |