P2574 XOR的艺术
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int n,m;
int main(){
string str;
cin>>n>>m;
cin>>str;
bitset<N> a(str),b(str);
b.set();
while(m--){
int op,l,r;
cin>>op>>l>>r;
if(op==0){
a^=((b>>(N-r+l-1))<<(l-1));
}else{
cout<<(a&((b>>(N-r+l-1))<<(l-1))).count()<<endl;
}
}
return 0;
}
output:
6
3
2