很神经,我把数据点下下来本地运行都是对的,但交上去就是0分(8WA+2TLE)(暴力解法
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
ll n,m;
ll num[N],bit[N];
char ch;
inline ll read(){
ll x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
int main(){
n=read();m=read();
for(ll i=1;i<=n;i++){
ch=getchar();
num[i]=ch-'0';
}
while(m--){
ll op,l,r;
op=read();l=read();r=read();
if(op==0){
for(ll i=l;i<=r;i++){
if(num[i]==1)
num[i]=0;
else
num[i]=1;
}
}
else{
ll sum=0;
for(ll i=l;i<=r;i++)
sum+=num[i];
cout<<sum<<endl;
}
}
return 0;
}