# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748956 | WongChun1234 | Tourism (JOI23_tourism) | C++14 | 1112 ms | 32332 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=100050;
int n,m,q,u,v,c[N],sz[N],ch[N],pre[N],post[N],lift[20][N],pt;
int hd[N],rpar[N],bit[N],lcaa,ans[N];
vector<int> adj[N];
vector<pair<int,int>> qs[N];
set<pair<int,int>> s;
void calcsize(int nde,int par){
sz[nde]=1;
for (int i:adj[nde]) if (i!=par){
calcsize(i,nde);
sz[nde]+=sz[i];
if (sz[i]>sz[ch[nde]]) ch[nde]=i;
}
}
void prehld(int nde,int par){
lift[0][nde]=rpar[nde]=par;
for (int i=1;i<19;i++) lift[i][nde]=lift[i-1][lift[i-1][nde]];
pre[nde]=++pt;
if (sz[nde]>1){
hd[ch[nde]]=hd[nde];
prehld(ch[nde],nde);
}
for (int i:adj[nde]) if (i!=par&&i!=ch[nde]){
hd[i]=i;
prehld(i,nde);
}
post[nde]=pt;
}
# | 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... |