Submission #502514

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
5025142022-01-06 07:46:08n00bie_1004Railway (BOI17_railway)C++17
100 / 100
122 ms35896 KiB
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
vector<ll> adj[100005];
ll l = 20;
ll dp[100005][20];
vector<ll> dep(100005);
ll timer = 0;
vector<ll> tin(100005), tout(100005);
bool comp(ll u, ll v){
return tin[u] < tin[v];
}
void precomp(ll v, ll par){
dep[v] = dep[par] + 1;
dp[v][0] = par;
for(ll i=1;i<l;i++)
dp[v][i] = dp[dp[v][i - 1]][i - 1];
tin[v] = ++timer;
for(auto u : adj[v])
if(u != par)
precomp(u, v);
tout[v] = ++timer;
}
ll is_ancs(ll u, ll v){
return tin[u] <= tin[v] && tout[u] >= tout[v];
}
ll find_LCA(ll u, ll v){
if(is_ancs(u, v))
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...