Submission #61691

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
616912018-07-26 10:42:18DiuvenMin-max tree (BOI18_minmaxtree)C++11
22 / 100
534 ms34512 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=70010, inf=2e9, LG=18;
int n;
pii E[MX];
vector<int> G1[MX];
int nu[MX], ri[MX];
int sp[MX][LG], dep[MX];
void dfs1(int v, int p, int d=1){
static int now=0;
nu[v]=++now; ri[v]=nu[v]; dep[v]=d;
for(int i=1; i<LG; i++) sp[v][i]=sp[sp[v][i-1]][i-1];
for(int x:G1[v]) if(nu[x]==0) sp[x][0]=v, dfs1(x,v,d+1), ri[v]=max(ri[v], ri[x]);
}
void init_tree(){
cin>>n;
for(int i=1; i<n; i++){
int u,v; cin>>u>>v;
G1[u].push_back(v);
G1[v].push_back(u);
E[i]={u,v};
}
dfs1(1,-1);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...