#include<bits/stdc++.h>
#include "stations.h"
using namespace std;
#define vi vector<int>
#define pb push_back
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
const int MAXN = 1005;
int st[MAXN],fin[MAXN],dep[MAXN],tim = 0;
vi adj[MAXN];
void dfs(int u,int p,int d){
if(d%2 == 0) st[u] = tim++;
dep[u] = d;
for(auto v:adj[u]){
if(v != p) dfs(v,u,d+1);
}
if(d%2 == 1) fin[u] = tim++;
}
vi label(int n, int k, vi u, vi v){
vi labels(n);
REP(i,n-1){
adj[u[i]].pb(v[i]);
adj[v[i]].pb(u[i]);
}
dfs(0,0,0);
for (int i = 0; i < n; i++){
if(dep[i]%2 == 0) labels[i] = st[i];
else labels[i] = fin[i];
}
return labels;
}
int find_next_station(int s, int t, vi c){
if(c.size() == 1) return c[0];
for(auto x:c){
if(x == t) return x;
}
sort(c.begin(),c.end());
if(s < c[0]){
if(t < s) return c.back();
for(auto x:c){
if(t < x) return x;
}
return c.back();
}
else{
if(t > s) return c[0];
for(auto x:c){
if(t > x) return x;
}
return c[0];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1445 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3038 ms |
528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1386 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1172 ms |
864 KB |
Output is correct |
2 |
Runtime error |
1149 ms |
2097156 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2226 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |