#include "stations.h"
#ifndef EVAL
#include "stub.cpp"
#endif
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) x.begin(), x.end()
const int NN = 1e3+5;
vector<int> edges[NN];
int tim;
vector<int> val;
int used[NN];
void dfs(int u, int t, int p){
used[u]=1;
if(t) val[u] = ++tim;
for(auto x:edges[u]){
if(used[u])continue;
dfs(x, (t ? 0 : 1), u);
}
if(!t) val[u] = ++tim;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
for(int i=0;i<n-1;i++){
edges[u[i]].pb(v[i]);
edges[v[i]].pb(u[i]);
}
val.resize(n);
tim = -1;
dfs(0, 1, -1);
return val;
}
int find_next_station(int s, int t, vector<int> c){
sort(all(c));
if(s < c[sz(c)-1]){
int p = c[sz(c)-1];
if(t >= p) return p;
auto tmp = lower_bound(all(c), t);
if(tmp == c.end())return 0;
return (*tmp);
}else{
int p = c[0];
if(t > s) return p;
int i = sz(c)-1;
while(c[i] > t && i > 0) i--;
return c[i];
}
}
/*
1
5 10
0 1
1 2
1 3
2 4
2
0 2
1 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
492 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
492 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
492 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
492 KB |
Invalid labels (duplicates values). scenario=0, label=0 |
2 |
Halted |
0 ms |
0 KB |
- |