#include<bits/stdc++.h>
using namespace std;
bitset<101> bt[101];
int main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
char x;
cin>>x;
bt[0][i]=x-'0';
}
for(int i=1;i<=q;i++){
string str;
cin>>str;
bt[i]=bt[i-1];
if(str=="toggle"){
int x;
cin>>x;
bt[i][x]=!bt[i][x];
} else {
int a,b;
cin>>a>>b;
int ans=0;
for(int j=0;j<i;j++){
int v=1;
for(int k=a;k<b;k++)
v&=bt[j][k];
ans+=v;
}
cout<<ans<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |