#include <bits/stdc++.h>
using namespace std;
int n, m, q, a[200005], vis[200005], par[200005];
vector<int> adj[200005];
void dfs(int u, int p){
vis[u] = vis[p] + 1;
par[u] = p;
for(auto v : adj[u]) if(v != p) dfs(v, u);
}
int lca(int v, int u){
if(vis[v] > vis[u]) lca(par[v], u);
if(vis[u] > vis[v]) lca(par[u], v);
if(v != u) lca(par[v], u);
return v;
}
int main(){
cin >> n >> m >> q;
for(int i = 0; i < n - 1; i++){
int u, v; cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int i = 0; i < n; i++) cin >> a[i];
dfs(1, 0);
while(q--){
int op; cin >> op;
if(op == 1){
int idx, val; cin >> idx >> val;
a[idx] = val;
}else{
int l, r, v, ptr_l = -1, ptr_r = -1;
cin >> l >> r >> v;
for(int u = l; u <= r; u++){
if(u != r && lca(a[u], a[u + 1]) == v){
ptr_l = u; ptr_r = u + 1;
break;
}else if(a[x] == v){
ptr_l = u; ptr_r = u;
break;
}
}
cout << ptr_l << ' ' << ptr_r << '\n';
}
}
}
Compilation message
treearray.cpp: In function 'int main()':
treearray.cpp:41:20: error: 'x' was not declared in this scope
41 | }else if(a[x] == v){
| ^