# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145148 | MKopchev | Min-max tree (BOI18_minmaxtree) | C++14 | 634 ms | 39132 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 nmax=7e4+42,inf=1e9;
int n;
vector<int> adj[nmax];
int parent[nmax];
int up[20][nmax],depth[nmax];
void dfs(int node,int par)
{
up[0][node]=par;
for(auto k:adj[node])
if(k!=par)
{
depth[k]=depth[node]+1;
dfs(k,node);
}
}
int lca(int u,int v)
{
if(depth[u]>depth[v])swap(u,v);
for(int i=19;i>=0;i--)
if(depth[v]-(1<<i)>=depth[u])v=up[i][v];
if(u==v)return u;
for(int i=19;i>=0;i--)
if(up[i][u]!=up[i][v])
{
u=up[i][u];
v=up[i][v];
# | 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... |