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<vector<int>> G;
vector<bool> V;
vector<int> L;
int dfs(int v, int d) {
V[v] = 0; L[v] = d;
for(auto x : G[v])
if(V[x]) return dfs(x, d+1);
return v;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
G.resize(n); V.resize(n, 1); L.resize(n);
for(int i = 0; i < n-1; i++) {
G[u[i]].push_back(v[i]);
G[v[i]].push_back(u[i]);
}
int ep = dfs(0, 0);
V.assign(n, 1);
dfs(ep, 0);
for(auto x : L) cout << x << ' ';
cout << '\n';
return L;
}
int find_next_station(int s, int t, vector<int> c) {
if(size(c) == 1) return c[0];
else if(t > s) return max(c[0], c[1]);
else return min(c[0], c[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... |