This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "stations.h"
//#include "stub.cpp"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=1005;
vector<int> g[N];
int cnt,D[N];
void dfs(int x, int p, vector<int> &v){
if(D[x]%2==0)
v[x]=cnt++;
for(auto it: g[x]){
if(it==p) continue;
D[it]=D[x]+1;
dfs(it,x,v);
}
if(D[x]%2)
v[x]=cnt++;
}
vector<int> label(int n, int k,vector<int> u, vector<int> v) {
for(int i=0;i<(int)u.size();i++){
g[u[i]].pb(v[i]);
g[v[i]].pb(u[i]);
}
vector<int> ans(n);
dfs(0,0,ans);
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
if(c.size()==1) return c[0];
int a=0;
if(c.back()<=s){
if(t>s || t<c[0]) return c[0];
a=1;
}
else{
if(t<s || t>c.back()) return c.back();
}
return c[lower_bound(c.begin(),c.end(),t+a)-c.begin()-a];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |