# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41563 | aome | Birthday gift (IZhO18_treearray) | C++14 | 3357 ms | 113572 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;
const int N = 200005;
int n, m, q;
int a[N];
int high[N];
int p[20][N];
vector<int> G[N];
set<int> s[2][N];
int lca(int u, int v) {
if (high[u] > high[v]) swap(u, v);
for (int i = 18; i >= 0; --i) {
if (high[p[i][v]] >= high[u]) v = p[i][v];
}
for (int i = 18; i >= 0; --i) {
if (p[i][v] != p[i][u]) v = p[i][v], u = p[i][u];
}
return (u == v) ? u : p[0][u];
}
void dfs(int u) {
for (auto v : G[u]) {
if (p[0][u] == v) continue;
p[0][v] = u, high[v] = high[u] + 1, dfs(v);
}
}
# | 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... |