#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solve(){
int n, q; cin>>n>>q;
string str[q+1];
cin>>str[0];
for(int i=1; i<=q; i++){
string mark;
cin>>mark;
if(mark == "toggle"){
int ind; cin>>ind;
string s = str[i-1];
if(s[ind-1] == '0') s[ind-1] = '1';
else s[ind-1]='0';
str[i] = s;
}
else{
int l, r; cin>>l>>r;
int ans = 0;
for(int j=0; j<=i-1; j++){
int flag =1;
for(int k = l-1; k<r-1; k++){
if(str[j][k] == '0') flag = 0;
}
ans+=flag;
}
cout<<ans<<"\n";
str[i] =str[i-1];
}
}
return;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1; //cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5076 ms |
20824 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
23 ms |
1496 KB |
Output is correct |
3 |
Correct |
47 ms |
1248 KB |
Output is correct |
4 |
Correct |
81 ms |
1364 KB |
Output is correct |
5 |
Runtime error |
975 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
1332 KB |
Output is correct |
2 |
Correct |
77 ms |
1480 KB |
Output is correct |
3 |
Correct |
46 ms |
1364 KB |
Output is correct |
4 |
Correct |
4 ms |
1372 KB |
Output is correct |
5 |
Runtime error |
218 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Execution timed out |
5076 ms |
20824 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |