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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int>>adj;
vector<int>l,r,ret;
int mark=0;
void dfs(int node,int par,int dep){
l[node]=mark++;
for(auto i:adj[node])
if(i!=par)dfs(i,node,1-dep);
r[node]=mark++;
ret[node]=(dep?l[node]:r[node]);
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
mark=0;
l=r=ret=vector<int>(n);
adj=vector<vector<int>>(n);
for(int i=0;i<n-1;i++){
adj[u[i]].push_back(v[i]);
adj[v[i]].push_back(u[i]);
}
dfs(0,0,1);
return ret;
}
int find_next_station(int s, int t,vector<int> c){
int m=(int)c.size();
if(s==0){
for(int i=m-1;i>=0;i--){
int in=(i==0?s+1:c[i-1]+1);
int out=c[i];
if(t>in && t<out){
return c[i];
}
}
return 0;
}
if(s<c[0]){///given is the in[s]
int p=c[m-1];
for(int i=m-2;i>=0;i--){
int in=(i==0?s+1:c[i-1]+1);
int out=c[i];
if(t>in && t<out){
return c[i];
}
}
return p;
}
else{///given is the out[s]
int p=c[0];
for(int i=1;i<m;i++){
int in=c[i];
int out=(i==m-1?s-1:c[i+1]-1);
if(t>in && t<out){
return c[i];
}
}
return p;
}
}
# | 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... |