记录编号 127973 评测结果 AAAAAAAAAA
题目名称 zwei 最终得分 100
用户昵称 Gravatarmzy 是否通过 通过
代码语言 C++ 运行时间 0.397 s
提交时间 2014-10-16 18:13:35 内存使用 0.97 MiB
显示代码纯文本
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;

int n,m;
int a[100005],c[100005];

int lowbit(int x)
{
	return x&(-x);
}

void up(int x,int add)
{
	while (x<=100005)
	{
		c[x] = c[x]^add;
		x += lowbit(x);
	}
}

int sum(int x)
{
	int sum2=0;
	while (x>0)
	{
		sum2 = sum2^c[x];
		x -= lowbit(x);
	}
	return sum2;
}

int main()
{
	freopen("zwei.in", "r", stdin);
	freopen("zwei.out", "w", stdout);
	
	scanf("%d%d", &n, &m);
	for (int i=1;i<=n;++i)
	{
		scanf("%d", &a[i]);
		up(i,a[i]);
	}
	for (int i=1;i<=m;++i)
	{
		int q,x,y;
		scanf("%d", &q);
		if (q)
		{
			scanf("%d%d", &x, &y);
			int s = sum(y)^sum(x-1);
			printf("%d\n", s);
		}
		else
		{
			scanf("%d%d", &x, &y);
			up(x,a[x]);
			up(x,y);
			a[x] = y;
		}
	}
	
	return 0;
}