#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include<cmath>
#include<set>
#include<algorithm>
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<pii,pii>
#define vi vector<int>
#define pb push_back
//#define p push
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-lopps")
#pragma GCC target("avx2")
using namespace std;
#define int long long
const int mod=9901,mxn=3*1e5+5,inf=1e18,lg=30,minf=-1e18;
vector<int>adj[mxn+10];
int h[mxn+10],up[mxn+10][lg+5],v[mxn+10],d[mxn+10];
void dfs(int cur,int p){for(auto i:adj[cur])if(i!=p)h[i]=h[cur]+1,up[i][0]=cur,dfs(i,cur);}
int lca(int a,int b){
if(h[a]<h[b])swap(a,b);
int k=h[a]-h[b];
for(int i=0;i<=lg;i++)if(k&(1<<i))a=up[a][i];
if(a==b)return a;
for(int i=lg;i>=0;i--)if(up[a][i]!=up[b][i])a=up[a][i],b=up[b][i];
return up[a][0];
}
int32_t main(){
fastio
int n,m,q;cin>>n>>m>>q;
for(int i=0;i<n-1;i++){
int a,b;cin>>a>>b;
adj[a].pb(b);
adj[b].pb(a);
}
dfs(1,-1);
for(int i=1;i<=lg;i++)for(int j=1;j<=n;j++)up[j][i]=up[up[j][i-1]][i-1];
for(int i=0;i<m;i++)cin>>v[i];
for(int i=0;i<m-1;i++)d[i]=lca(v[i],v[i+1]);
while(q--){
int t;cin>>t;
if(t==1){
int pos,val;cin>>pos>>val;
v[--pos]=val;
d[pos]=lca(v[pos],v[pos+1]);
if(pos)d[pos-1]=lca(v[pos-1],v[pos]);
}
else{
int l,r,ver;cin>>l>>r>>ver;
bool yes=false;
l--,r--;
for(int i=l;i<r;i++){
if(d[i]==ver&&!yes)cout<<i+1<<" "<<i+2,yes=true;
if(v[i]==ver&&!yes)cout<<i+1<<" "<<i+1,yes=true;
}
if(!yes)cout<<-1<<" "<<-1;
cout<<'\n';
}
}
}
Compilation message
treearray.cpp:30:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
30 | #pragma GCC optimize ("03,unroll-lopps")
| ^
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
31 | #pragma GCC target("avx2")
| ^
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
treearray.cpp:31:26: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
n=5 |
2 |
Incorrect |
4 ms |
12380 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
n=5 |
2 |
Incorrect |
4 ms |
12380 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
n=5 |
2 |
Incorrect |
4 ms |
12380 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12380 KB |
n=5 |
2 |
Incorrect |
4 ms |
12380 KB |
Jury has the answer but participant has not |
3 |
Halted |
0 ms |
0 KB |
- |