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;
#include "stations.h"
typedef long long ll;
vector<vector<int>>adj;
vector<int>ret;
void dfs(int node,int mark=0,int par=-1){
if(mark>1000){
return;
}
ret[node]=mark;
for(auto i:adj[node]){
if(i!=par)dfs(i,mark+1,node);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v){
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]);
}
int root=0;
for(int i=0;i<n;i++){
if(adj[i].size()==1)root=i;
}
dfs(root,root);
return ret;
}
int find_next_station(int s, int t,vector<int> c){
if (c.size() == 1)
return c[0];
for (int l : c)
if (l == t)
return t;
if (t > s)
return c.back();
return c[0];
}
# | 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... |