#include<bits/stdc++.h>
using namespace std;
void PlayGround() {
int n, q;
cin>>n>>q;
assert(max(n, q)<=100);
vector<string>state(1);
cin>>state[0];
for(int i=0; i<q; ++i) {
string type;
cin>>type;
string cur = state.back();
if(type=="toggle") {
int j;
cin>>j;
--j;
cur[j] = cur[j]=='0'?'1':'0';
state.push_back(cur);
} else {
state.push_back(cur);
int a, b;
cin>>a>>b;
--a, --b;
int ans = 0;
for(int j=0; j<=i; ++j) {
bool ok = true;
for(int k=a; k<b; ++k) {
ok &= state[j][k]=='1';
}
ans += ok;
}
cout<<ans<<'\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
PlayGround();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Output is correct |
2 |
Correct |
0 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
312 KB |
Output is correct |
8 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
9 |
Halted |
0 ms |
0 KB |
- |