记录编号 | 186527 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | zwei | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.799 s | ||
提交时间 | 2015-09-12 23:14:40 | 内存使用 | 4.51 MiB | ||
#include<cstdio> #include<iostream> #include<cmath> #include<cstring> using namespace std; int n,m; int P[100010],tot=1; class miku { public: int sum; int r,l; int lson,rson; }T[200010]; void build(int l,int r) { int mid=(l+r)/2,root=tot; if(l==r) { T[root].l=T[root].r=l; T[root].lson=T[root].rson=-1; T[root].sum=P[l]; } else { T[root].lson=++tot;build(l,mid); T[root].rson=++tot;build(mid+1,r); T[root].l=l;T[root].r=r;T[root].sum=T[T[root].lson].sum^T[T[root].rson].sum; } return; } void change(int root,int x,int y) { if(x<T[root].l||x>T[root].r) return; if(T[root].r==T[root].l) { T[root].sum=y; return; } change(T[root].lson,x,y); change(T[root].rson,x,y); T[root].sum=T[T[root].lson].sum^T[T[root].rson].sum; } int get(int root,int l,int r) { if(r<T[root].l||l>T[root].r) return 0; if(l<=T[root].l&&r>=T[root].r) return T[root].sum; else { int tot=0; tot^=get(T[root].lson,l,r); tot^=get(T[root].rson,l,r); return tot; } } 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",&P[i]); build(1,n); int a,x,y,l,r; for(int i=1;i<=m;i++) { scanf("%d",&a); if(a==0) { scanf("%d%d",&x,&y); //cout<<x<<" "<<y<<endl; change(1,x,y); } if(a==1) { scanf("%d%d",&l,&r); printf("%d\n",get(1,l,r)); } } return 0; }