数组似乎没爆啊
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read(){
char ch = getchar(); int x = 0, f = 1;
for(; !isdigit(ch) and ch != '-'; ch = getchar());
if(ch == '-') f = -1, ch = getchar();
for(; isdigit(ch); x = x * 10 + ch - 48, ch = getchar());
return x * f;
}
const int N = 1e5 + 10;
void www(int x) { if(x < 0) putchar('-'), x = -x; if(x > 9) www(x / 10); putchar(x % 10 + '0'); }
void write(int x) {www(x); putchar('\n'); }
pair<int, int> p[N], use;
class Seg{
public:
pair<int, int> tree[N << 2];
void pushup(int cur){
tree[cur].first = (tree[cur << 1].first | tree[cur << 1 | 1].first);
tree[cur].second = (tree[cur << 1].second | tree[cur << 1 | 1].second);
}
void build(int cur, int l, int r, pair<int, int> a[]){
if(l == r){
tree[cur] = a[l];
return;
}
int mid = (l + r) >> 1;
build(cur << 1, l, mid, a), build(cur << 1 | 1, mid + 1, r, a);
pushup(cur);
}
void update(int cur, int l, int r, int x, pair<int, int> val){
if(l == r and l == x){
tree[cur] = val;
return;
}
int mid = (l + r) >> 1;
if(x <= mid) update(cur << 1, l, mid, x, val);
else update(cur << 1 | 1, mid + 1, r, x, val);
pushup(cur);
}
pair<int, int> ask(int cur, int l, int r, int x, int y){
if(l >= x and r <= y){
//puts("OK"); cout << l << " " << r << " -+-+- " << x << " " << y << "\n";
return tree[cur];
}
int mid = (l + r) >> 1; pair<int, int> ans, ans2;
if(x <= mid) ans = ask(cur << 1, l, mid, x, y);
if(y > mid) ans2 = ask(cur << 1 | 1, mid + 1, r, x, y), ans.first |= ans2.first, ans.second |= ans2.second;
return ans;
}
}A;
int lowbit(int x){
return x & (-x);
}
int calc_(int x){
int ans = 0;
while(x != 0){
x -= lowbit(x);
ans++;
}
//cout << "calc_" << ans << "\n";
return ans;
}
int calc__(int x){
int ans = 0;
while(x != 0){
ans++;
x >>= 1;
}
//cout << "calc__" << ans << "\n";
return ans;
}
int calc(int x){ return calc__(x) - calc_(x); }
int qpow(int x, int p){
int ans = 1;
while(p != 0){
if(p & 1) ans *= x;
x = x * x;
p >>= 1;
}
return ans;
}
signed main(signed argc, char const *argv[]){
int x1, x2, n, m, q, cnt = 0; n = read(), m = read(); q = read();
char ch;
for(int i = 1; i <= m; i++, getchar()){
x1 = x2 = 0;
for(int j = 1; j <= n; j++){
ch = getchar();
if(ch == '1'){ x1 = ((x1 << 1) | 1); x2 = (x2 << 1); }
else if(ch == '0') { x1 = (x1 << 1); x2 = ((x2 << 1) | 1); }
else { x1 = (x1 << 1); x2 = (x2 << 1); }
}
//cout << x2 << " " << x1 << "\n";
p[i] = make_pair(x2, x1); // 0 : 1
}
A.build(1, 1, n, p);
//cout << A.tree[2].first << " -- " << A.tree[2].second << "\n";
int l, r;
for(int i = 1; i <= q; i++){
int opt = read();
if(opt == 0){
l = read(), r = read();
use = A.ask(1, 1, n, l, r);
//cout << (use.first & use.second) << "aa" << "\n";
if((use.first & use.second) != 0){ puts("0"); cnt ^= 0;}
else{
int user = calc(use.first | use.second);
//write(qpow(2, user));
cnt ^= qpow(2, user);
}
}
else {
int x = read(); x1 = x2 = 0;
for(int i = 1; i <= n; i++){
ch = getchar();
if(ch == '1') { x1 = ((x1 << 1) | 1); x2 = (x2 << 1); }
else if(ch == '0') { x1 = (x1 << 1); x2 = ((x2 << 1) | 1); }
else { x1 = (x1 << 1), x2 = (x2 << 1); }
}
A.update(1, 1, n, x, make_pair(x2, x1));
}
}
write(cnt);
}