#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n, q; cin >> n >> q;
vector<bool> a(n);
for (int i = 0; i < n; i++){
char c; cin >> c;
a[i] = c - '0';
}
vector<int> lst(n, -1), res(n);
for (int qq = 0; qq < q; qq++){
string ty; cin >> ty;
if (ty == "toggle"){
int i; cin >> i;
i--;
if (a[i])
res[i] += i - lst[i] + 1;
a[i] = !a[i];
lst[i] = qq;
}else{
int l, r; cin >> l >> r;
l--, r--;
int ans = res[l];
if (a[l])
ans += qq - lst[l];
cout << ans << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
63 ms |
1692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |