记录编号 |
186564 |
评测结果 |
AAAAAAAAAA |
题目名称 |
zwei |
最终得分 |
100 |
用户昵称 |
devil |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.587 s |
提交时间 |
2015-09-13 15:37:55 |
内存使用 |
1.46 MiB |
显示代码纯文本
- #include <cstdlib>
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <map>
- #include <stack>
- #include <queue>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef unsigned int uint;
- const int inf=1061109567;
- const int maxn=100010;
- const int maxm=21;
- const int mod=10007;
-
- int tree[3*maxn];
-
- void build_tree(int l,int r,int dir)
- {
- if(l==r)
- {
- scanf("%d",&tree[dir]);
- return;
- }
- int m=(l+r)/2;
- build_tree(l,m,dir*2);
- build_tree(m+1,r,dir*2+1);
- tree[dir]=tree[dir*2]^tree[dir*2+1];
- }
-
- void modify(int x,int y,int l,int r,int dir)
- {
- if(l==r&&l==x)
- {
- tree[dir]=y;
- return;
- }
- int m=(l+r)/2;
- if(x<=m) modify(x,y,l,m,dir*2);
- else modify(x,y,m+1,r,dir*2+1);
- tree[dir]=tree[dir*2]^tree[dir*2+1];
- }
-
- int query(int ql,int qr,int l,int r,int dir)
- {
- if(ql<=l&&qr>=r) return tree[dir];
- if(ql>r||qr<l) return 0;
- int m=(l+r)/2;
- int t1=query(ql,qr,l,m,dir*2);
- int t2=query(ql,qr,m+1,r,dir*2+1);
- return t1^t2;
- }
-
- int main()
- {
- freopen("zwei.in","r",stdin);
- freopen("zwei.out","w",stdout);
- //clock_t st=clock();
- int n,m;scanf("%d%d",&n,&m);
- build_tree(1,n,1);
- int a,x,y;
- int ans;
- while(m--)
- {
- scanf("%d%d%d",&a,&x,&y);
- if(a==0)
- {
- modify(x,y,1,n,1);
- }
- else
- {
- ans=query(x,y,1,n,1);
- printf("%d\n",ans);
- }
- }
- //clock_t ed=clock();
- //printf("\nTime used : %.7lf Ms\n",double(ed-st)/CLOCKS_PER_SEC);
- return 0;
- }