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;
vector<int> grafo[1005];
int val[1005],tt;
void dfs(int nodo, int mode, int last){
if(mode==0)val[nodo]=tt++;
for(auto i : grafo[nodo]){
if(i!=last)dfs(i,mode^1,nodo);
}
if(mode==1)val[nodo]=tt++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
std::vector<int> labels(n);
for(int i=0;i<n;i++)grafo[i].clear();
tt=0;
for(int i=0;i<n-1;i++){
grafo[u[i]].push_back(v[i]);
grafo[v[i]].push_back(u[i]);
}
dfs(0,0,-1);
for (int i = 0; i < n; i++) {
//cout<<i<<" "<<val[i]<<"\n";
labels[i] = val[i];
}
return labels;
}
int find_next_station(int s, int t, std::vector<int> c) {
bool mode;
if(c[0]<s)mode=1;
else mode=0;
if(mode){
int last=s;
for(int i=c.size()-1;i>0;i--){
if(t>=c[i] && t<last)return c[i];
last=c[i];
}
return c[0];
}else{
int last=s;
int st;
if(s==0)st=c.size();
else st=c.size()-1;
for(int i=0;i<st;i++){
if(t>last && t<=c[i])return c[i];
last=c[i];
}
return c[c.size()-1];
}
}
# | 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... |