跳到正文

剪贴板

剪贴板 xt0gs14j

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include<bits/stdc++.h>
#define inl inline
#define int long long
#define lll __int128
#define fst ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,x,y) for(int i=x;i<=(y);++i)
#define per(i,x,y) for(int i=x;i>=(y);--i)
#define rpr(i,x,y,z) for(int i=x;i<=(y);i+=z)
#define epe(i,x,y,z) for(int i=x;i>=(y);i-=z)
#define repe(i,x,y) for(i=x;i<=(y);++i)
#define endl '\n'
#define INF INT_MAX
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define lcm(x,y) x/__gcd(x,y)*y
#define ull unsigned long long
#define prr make_pair
#define pii pair<int,int>
#define gt(s) getline(cin,s)
#define at(x,y) for(const auto &x:y)
#define ff fflush(stdout)
#define mt(x,y) memset(x,y,sizeof(x))
#define idg isdigit
#define fp(s) string ssss=s;freopen((ssss+".in").c_str(),"r",stdin);freopen((ssss+\
".out").c_str(),"w",stdout);
#define sstr stringstream
#define all(x) x.begin(),x.end()
#define mcy(a,b) memcpy(a,b,sizeof(b))
#define ui unsigned
#define si signed
#define eb emplace_back
#define pff(x) ((x)*(x))
#define eush emplace
#define double long double
#define pdi pair<double,int>
#define gc getchar
#define pc putchar
//#define gc getchar_unlocked
//#define pc putchar_unlocked
using namespace std;
const int N=(1ll<<20)+5,MOD=998244353;
int c[N],c2[N],ans,n,d;
mt19937 rnd(time(0));
inl int query(int x){
	if(!x) return 0;
	int p=0,sum=0,u=x;
	while(u){
		int a=u&-u;
		p^=c[a];
		sum^=1;
		u^=a;
	}
	if(!sum) p^=c[0];
//	cout<<x<<' '<<sum<<' '<<p<<endl;
	return p!=c[x];
}
inl void init(){
	ans=0;
	rep(i,0,(1ll<<n)-1) ans+=query(i);
}
si main(){
	fst;
	int m,q;
	cin>>n>>m>>q;
	d=rnd()&(1ll<<n)-1;
//	cout<<d<<endl;
	rep(i,0,(1ll<<n)-1) cin>>c[i];
	rep(i,0,(1ll<<n)-1) c2[i]=c[i];
	rep(i,0,(1ll<<n)-1) c[i]=c2[i^d];
	init();
	if(!ans) cout<<(1ll<<m)%MOD<<endl;
	else cout<<0<<endl;
	rep(i,1,q){
		int x,y;
		cin>>x>>y;
		x^=d;
		if(!(x&x-1)){
			c[x]=y;
			init();
		}else{
			ans-=query(x);
			c[x]=y;
			ans+=query(x);
		}
		if(!ans) cout<<(1ll<<m)%MOD<<endl;
		else cout<<0<<endl;
	}
	return 0;
}