# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89721 | Abelyan | Birthday gift (IZhO18_treearray) | C++14 | 1678 ms | 107212 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;
const int LG=log2(N)+3;
vector<int> g[N];
int anc[N][LG];
int n,m,q,l;
int in[N],out[N],timer;
void dfs(int v,int par=0){
in[v]=timer++;
anc[v][0]=par;
for (int i=1;i<=l;i++){
anc[v][i]=anc[anc[v][i-1]][i-1];
}
for (auto to:g[v]){
if (to==par)continue;
dfs(to,v);
}
out[v]=timer++;
}
bool is_anc(int a,int b){
if (b==0 || a==b)return true;
if (in[a]>in[b] && in[a]<out[b])return true;
return false;
}
# | 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... |