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], labels;
void dfs(int u, int p, int l) {
labels[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) {
labels = vector<int>(n);
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 labels;
}
int find_next_station(int s, int t, vector<int> c) {
return s < t ? c[1] : 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... |