#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(x) (cout << (x))
#else
#define dbg(x)
#endif
typedef long long ll;
using vi =vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
#define pb push_back
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define trace(x) for (auto &el : x) {dbg(el); dbg(" ");}
int n, k;
vi U, V, labels;
vvi adj;
void dfs(int u, int p, int label) {
labels[u] = label;
for (auto &v : adj[u]) {
if (v == p) continue;
dfs(v, u, label+1);
}
}
vi label(int N, int K, vi x, vi y) {
n = N; k = K;
U = x; V = y;
vi deg(n); for (int i = 0; i < n - 1; i++) deg[U[i]]++, deg[V[i]]++;
int root = 0; while (deg[root] != 1) root++;
labels.resize(n);
dfs(root, root, 0);
return labels;
}
int find_next_station(int s, int t, vi c) {
return t < s ? 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... |