# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
634353 | tabr | Stations (IOI20_stations) | C++17 | 0 ms | 0 KiB |
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;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif
// editorial?
vector<int> label(int n, int k, vector<int> x, vector<int> y) {
vector<vector<int>> g(n);
for (int i = 0; i < n - 1; i++) {
g[x[i]].emplace_back(y[i]);
g[y[i]].emplace_back(x[i]);
}
vector<int> depth(n), sz(n);
{
function<void(int, int)> Dfs = [&](int v, int p) {
sz[v]++;
for (int to : g[v]) {
if (to == p) {
continue;
}
depth[to] = depth[v] + 1;
Dfs(to, v);
sz[v] += sz[to];
}
};
Dfs(0, -1);