记录编号 |
204933 |
评测结果 |
AAAAAAAAAA |
题目名称 |
平凡的测试数据 |
最终得分 |
100 |
用户昵称 |
dashgua |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.147 s |
提交时间 |
2015-11-04 18:45:47 |
内存使用 |
3.75 MiB |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>
template<class Num>void read(Num &x)
{
char c; int flag = 1;
while((c = getchar()) < '0' || c > '9')
if(c == '-') flag *= -1;
x = c - '0';
while((c = getchar()) >= '0' && c <= '9')
x = (x<<3) + (x<<1) + (c-'0');
x *= flag;
return;
}
template<class Num>void write(Num x)
{
if(!x) {putchar('0');return;}
if(x < 0) putchar('-'), x = -x;
static char s[20];int sl = 0;
while(x) s[sl++] = x%10 + '0',x /= 10;
while(sl) putchar(s[--sl]);
}
const int maxn = 300050;
int N, M;
int w[maxn], fa[maxn], g[maxn];
int find(int a)
{
if(a == fa[a]) return a;
else
{
find(fa[a]);
g[a] ^= g[fa[a]];
fa[a] = fa[fa[a]];
return fa[a];
}
}
int main()
{
freopen("td.in","r",stdin);
freopen("td.out","w",stdout);
read(N), read(M);
for(int i = 1; i <= N; i++) read(w[i]);
for(int i = 1; i <= N; i++) fa[i] = i;
while(M--)
{
int a, b, t;
read(t);
if(t == 1)
{
read(a), read(b);
g[find(a)] = w[fa[a]];
fa[fa[a]] = b;
}
else
{
read(a);
write(w[find(a)] ^ g[a]);
puts("");
}
}
fclose(stdin);
fclose(stdout);
return 0;
}