//debug icin gdb kullanmayi dene
#include<bits/stdc++.h>
using namespace std;
#define mods 1000000007
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define rs resize
#define pii pair<lint,lint>
#define piii pair<lint,pair<lint,lint> >
#define inf LLONG_MAX-7
#define vvL vector<vector<lint> >
#define vvB vector<vector<bool> >
#define vvvL vector<vector<vector<lint> > >
#define vL vector<lint>
#define vpii vector<pii>
#define vB vector<bool>
typedef long long int lint;
typedef unsigned long long int ulint;
lint fastpow(lint tab,lint us){
if(tab==0) return 0;
if(tab==1) return 1;
if(us==0) return 1;
if(us==1) return tab%mods;
tab%=mods;
if(us%2==1) return tab*fastpow(tab,us-1)%mods;
lint a=fastpow(tab,us/2)%mods;
return a*a%mods;
}
lint t=1,n,q;
vector<string> tum;
void solve(){
lint i,j,a,b,k;
cin>>n>>q;
string s,str;
cin>>s;
// cez.rs(n+5,0);
// mev.rs(n+5,-1);
tum.rs(q+5);
tum[0]=s;
// for(i=1;i<=n;i++) if(s[i-1]=='0') mev[i]=0;
for(j=1;j<=q;j++){
cin>>str;
if(str=="query"){
cin>>a>>b;
a--,b--;
lint ret=0;
for(i=0;i<j;i++){
for(k=a;k<b;k++) if(tum[i][k]=='0') break;
if(k==b) ret++;
}
cout<<ret<<endl;
tum[j]=tum[j-1];
}else{
cin>>a;
a--;
s=tum[j-1];
if(s[a]=='0') s[a]=1;
else s[a]=0;
tum[j]=s;
}
}
return;
}
int main(){
// freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// cin>>t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5078 ms |
17012 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1228 KB |
Output is correct |
2 |
Correct |
3 ms |
1356 KB |
Output is correct |
3 |
Correct |
5 ms |
1356 KB |
Output is correct |
4 |
Correct |
127 ms |
1324 KB |
Output is correct |
5 |
Runtime error |
251 ms |
524292 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1348 KB |
Output is correct |
2 |
Incorrect |
6 ms |
1356 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |