# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
41616 | cheater2k | Birthday gift (IZhO18_treearray) | C++14 | 1729 ms | 75420 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];
vector<int> G[N];
int dep[N], par[N][18];
set<int> v1[N], v2[N];
void dfs(int u) {
for (int v : G[u]) if (v != par[u][0]) {
par[v][0] = u;
dep[v] = dep[u] + 1;
dfs(v);
}
}
int lca(int u, int v) {
if (dep[u] < dep[v]) swap(u, v);
for (int i = 17; i >= 0; --i) if (dep[par[u][i]] >= dep[v]) u = par[u][i];
for (int i = 17; i >= 0; --i) if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
return u == v ? u : par[u][0];
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> m >> q;
for (int i = 1; i < n; ++i) {
# | 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... |