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 <iostream>
#include <vector>
#include "stations.h"
using namespace std;
vector <vector <int>> g(1e3);
vector <int> sz(1e3, 0);
vector <int> lbl;
void dfs1(int x) {
sz[x] = 1;
for (int i : g[x]) {
if (sz[i]) continue;
dfs1(i);
sz[x] += sz[i];
}
}
void dfs2(int x, int l, int r, bool b) {
if (b) { lbl[x] = l; l++; }
else { lbl[x] = r; r--; }
for (int i : g[x]) {
if (lbl[i] > -1) continue;
dfs2(i, l, l + sz[i] - 1, !b);
l += sz[i];
}
}
vector <int> label(int n, int k, vector <int> u, vector <int> v) {
lbl.assign(n, -1);
for (int i = 0; i < n - 1; i++) {
g[u[i]].push_back(v[i]);
g[v[i]].push_back(u[i]);
}
dfs1(0);
dfs2(0, 0, n - 1, true);
cout << endl;
for (int i : lbl) cout << i << endl;
cout << endl;
return lbl;
}
int find_next_station(int s, int t, vector <int> c) {
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... |