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 <bits/stdc++.h>
using namespace std;
const int N = 1000;
int degree[N];
vector<int> g[N], lbl;
void dfs(int u, int p, int l) {
lbl[u] = l;
for (int v : g[u]) {
if (v == p) {
continue;
}
dfs(v, u, l+1);
}
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
lbl = vector<int>(n);
for (int i=0 ; i<n ; i++) {
degree[i] = 0;
g[i].clear();
}
for (int i=0 ; i<n-1 ; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
degree[u[i]]++;
degree[v[i]]++;
}
for (int i=0 ; i<n ; i++) {
if (degree[i] == 1) {
dfs(i, -1, 0);
break;
}
}
return lbl;
}
int find_next_station(int s, int t, vector<int> c) {
return s < t ? s+1 : s-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... |