# codeforces 339d（线段树）

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
#define maxn 200200
int a[maxn];
int sum[maxn<<2];
void build(int l,int r,int rt,int op)
{
if(l==r)
{
sum[rt] = a[l];
return;
}
int mid = (l+r)>>1;
build(l,mid,rt<<1,1-op);
build(mid+1,r,rt<<1|1,1-op);
if(op==1) sum[rt] = sum[rt<<1]|sum[rt<<1|1];
else sum[rt] = sum[rt<<1] ^ sum[rt<<1|1];
}
void update(int p,int l,int r,int rt,int b,int op)
{
if(l==r)
{
sum[rt]=b;
return;
}
int mid = (l+r)>>1;
if(p>mid) update(p,mid+1,r,rt<<1|1,b,1-op);
else update(p,l,mid,rt<<1,b,1-op);
if(op==1) sum[rt] = sum[rt<<1]|sum[rt<<1|1];
else sum[rt] = sum[rt<<1] ^ sum[rt<<1|1];
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=1;i<=(1<<n);i++)
{
scanf("%d",&a[i]);
}
int cnt = 1<<n;
int p,b;
build(1,cnt,1,n%2);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&p,&b);
update(p,1,cnt,1,b,n%2);
printf("%d\n",sum[1]);
}
return 0;
}

#### CodeForces 339D Xenia and Bit Operations（线段树点修改）

2015-08-23 20:30:17

#### Codeforces 768B Code For 1 线段树思想

2017-02-22 22:01:55

#### CodeForces 343D Water Tree dfs序 + 线段树

2016-05-24 12:14:58

#### Codeforces 339D Xenia and Bit Operations 线段树

2017-02-17 19:36:01

#### codeforces 777E dp+线段树+离散化

2017-03-02 11:27:23

#### codeforces-914D Bash and a Tough Math Puzzle(线段树维护gcd)

2018-04-08 23:43:53

#### Codeforces 899F Letters Removing [线段树]

2017-12-17 21:27:08

#### [均摊复杂度线段树] Codeforces #438D. The Child and Sequence

2017-09-28 11:33:50

#### CodeForces - 620E —— 线段树 dfs序

2018-03-19 22:38:35

#### codeforces 474F F. Ant colony(线段树+数论)

2015-08-25 09:52:34