# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61691 | Diuven | Min-max tree (BOI18_minmaxtree) | C++11 | 534 ms | 34512 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;
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);
}
# | 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... |