| 比赛 | 
    9.6 | 
    评测结果 | 
    AAATTTTTTA | 
    | 题目名称 | 
    平凡的测试数据 | 
    最终得分 | 
    40 | 
    | 用户昵称 | 
    郑霁桓 | 
    运行时间 | 
    12.003 s  | 
    | 代码语言 | 
    C++ | 
    内存使用 | 
    5.22 MiB  | 
    | 提交时间 | 
    2024-09-06 20:24:09 | 
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
long long n,m,x,y,fa[300005],as,p;
long long f(long long x){
    if(fa[x]!=x){
        fa[x]=f(fa[x]);
    }
    return fa[x];
}
struct nm{
    long long v,id,nt;
}a[300005];
int main(){
    freopen("td.in","r",stdin);
    freopen("td.out","w",stdout);
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i].v);
        a[i].id=i;
    }
    while(m--){
        scanf("%lld%lld",&p,&x);
        if(p==1){
            scanf("%lld",&y);
            a[x].nt=y;
        }else{
            as=a[x].v;
            while(a[x].nt){
                as^=a[a[x].nt].v;
                x=a[x].nt;
            }
            printf("%lld\n",as);
        }
    }
    return 0;
}