# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74508 | win11905 | Birthday gift (IZhO18_treearray) | C++11 | 1665 ms | 137348 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 = 2e5+5;
int n, m, q, A[N];
int par[N][18], dep[N];
vector<int> g[N];
set<int> pos[N], lca_pos[N];
void init_lca(int u, int p) {
for(int i = 1; i < 18; ++i) par[u][i] = par[par[u][i-1]][i-1];
for(int v : g[u]) if(v != p) par[v][0] = u, dep[v] = dep[u] + 1, init_lca(v, u);
}
int get_lca(int u, int v) {
if(dep[u] < dep[v]) swap(u, v);
for(int i = 17; ~i; --i) if(dep[par[u][i]] >= dep[v]) u = par[u][i];
if(u == v) return u;
for(int i = 17; ~i; --i) if(par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
return par[u][0];
}
int main() {
scanf("%d %d %d", &n, &m, &q);
for(int i = 1, u, v; i < n; ++i) {
scanf("%d %d", &u, &v);
g[u].emplace_back(v), g[v].emplace_back(u);
}
for(int i = 1; i <= n; ++i) pos[i].emplace(m+1), lca_pos[i].emplace(m+1);
Compilation message (stderr)
# | 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... |