# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1037975 | karok | Race (IOI11_race) | 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;
#define int long long
struct Edges {
int target, weight;
};
const int MAXN = 200000;
const int MAXK = 1000000;
int n, k;
vector<vector<Edges>> adj(MAXN);
int tree_size[MAXN] = {};
bool is_removed[MAXN];
int get_tree_size(int cur_vertex, int parent = -1) {
int &res = tree_size[cur_vertex];
res = 1;
for (auto [v, w] : adj[cur_vertex]) {
if (v == parent || is_removed[v])continue;
continue;
res += get_tree_size(v, cur_vertex);
}
return res;
}
int get_centroid(int cur_vertex, int n, int parent = -1) {
for (auto [v, w] : adj[cur_vertex]) {
if (parent == v || is_removed[v])