#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 20;
int a[1<<maxn];
int n, m, u, v;
void Build() {
int p = 1 << n, res = 0;
while(p) {
p >>= 1;
for(int i = p; i < 2*p; ++i) {
if(res&1) a[i] = a[i<<1] ^ a[(i<<1)+1];
else a[i] = a[i<<1] | a[(i<<1)+1];
}
res++;
}
}
void Update(int p) {
int res = 0;
while(p) {
p >>= 1;
if(res&1) a[p] = a[p<<1] ^ a[(p<<1)+1];
else a[p] = a[p<<1] | a[(p<<1)+1];
res++;
}
}
int main() {
scanf("%d%d", &n, &m);
int len = 1 << n, p = len;
for(int i = 0; i < len; ++i) scanf("%d", &a[len+i]);
Build();
while(m--) {
int u, v; scanf("%d%d", &u, &v);
a[p+u-1] = v;
Update(p+u-1);
printf("%d\n", a[1]);
}
return 0;
}
CodeForces 339D
最新推荐文章于 2020-12-05 21:22:14 发布