# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729384 | jampm | Election Campaign (JOI15_election_campaign) | C++17 | 1071 ms | 30888 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;
using ll = long long int;
const int Mxn = 1e5 + 1;
const int mxn = 2e5 + 1;
//hld
//nomás porq soy un mamador y es menos código hacer lca así que con binary lifting
int tin[Mxn], tout[Mxn], Sz[Mxn], head[Mxn], P[Mxn], Depth[Mxn], cnt = 1;
vector<int> g[Mxn];
void get_sz(int node = 1, int parent = 1) {
Sz[node] = 0; Depth[node] = Depth[parent] + 1; P[node] = parent;
if (g[node][0] == parent) swap(g[node][0], g[node].back());
for (auto & child : g[node]) {
if (child == parent) continue;
get_sz(child, node); Sz[node] += Sz[child];
if (Sz[child] > Sz[g[node][0]]) swap(child, g[node][0]);
}
}
void dfs_hld(int node = 1, int parent = 1) {
tin[node] = cnt++;
for (auto child : g[node]) {
if (child == parent) continue;
head[child] = (child == g[node][0]) ? head[node] : child;
dfs_hld(child, node);
}
tout[node] = cnt++;
}
void init_hld() {head[1] = 1; Depth[1] = 0; get_sz(), dfs_hld();}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |