Submission #42294

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
422942018-02-25 15:09:12minhtung0404Birthday gift (IZhO18_treearray)C++14
100 / 100
1549 ms113576 KiB
//https://oj.uz/problem/view/IZhO18_treearray
#include<bits/stdc++.h>
const int N = 2e5 + 5;
using namespace std;
vector <int> adj[N];
set <int> ans[2][N];
int n, m, q, a[N], p[N][20], d[N];
void dfs(int u){
for (int i = 0; i < (int)adj[u].size(); i++){
int v = adj[u][i];
if (v == p[u][0]) continue;
d[v] = d[u] + 1; p[v][0] = u;
dfs(v);
}
}
int lca(int u, int v){
if (d[u] < d[v]) swap(u, v);
for (int i = 19; i >= 0; i--) if (d[u] - (1 << i) >= d[v]) u = p[u][i];
for (int i = 19; i >= 0; i--) if (p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
return ((u != v) ? p[u][0] : u);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
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...