This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
ll n,q;
string s[110];
int main(){
cin>>n>>q;
cin>>s[0];
for(int t=1;t<=q;t++){
s[t]=s[t-1];
string typ; cin>>typ;
if(typ=="query"){
ll a,b; cin>>a>>b; a--,b--;
ll ans=0;
for(int i=0;i<t;i++){
ll cnt=0;
for(int j=a;j<b;j++){
if(s[i][j]=='0')cnt++;
}
ans+=(cnt==0);
}
cout<<ans<<endl;
}
if(typ=="toggle"){
ll x; cin>>x; x--;
if(s[t][x]=='0')s[t][x]='1';
else s[t][x]='0';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |