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 <bits/stdc++.h>
using namespace std;
const int mxn = 555;
string s;
string state[mxn];
int N,Q;
bool check(string &s,int a,int b){
for(int i = a;i<b;i++){
if(s[i] == '0')return false;
}
return true;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>Q;
if(N>mxn||Q>mxn)return 0;
cin>>s;
s = "#"+s;
state[0] = s;
for(int i = 1;i<=Q;i++){
string tp;
cin>>tp;
state[i] = state[i-1];
if(tp[0] == 'q'){
int a,b;
cin>>a>>b;
int ans = 0;
for(int j = 0;j<i;j++){
if(check(state[j],a,b))ans++;
}
cout<<ans<<'\n';
}
else{
int a;
cin>>a;
state[i][a] = (state[i][a] == '0'?'1':'0');
}
}
return 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... |