#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
char x;
cin >> x;
if(x == '1') {
a[i] = 1;
}
else {
a[i] = 0;
}
}
vector<int> op(q + 1, - 1);
for(int i = 1; i <= q; i++) {
string type;
cin >> type;
if(type == "query") {
int l, r;
cin >> l >> r;
r -= 1;
int ans = 0;
vector<int> b(n + 1);
for(int j = 1; j <= n; j++) {
b[j] = a[j];
}
for(int j = 1; j <= i; j++) {
if(op[j] != - 1) {
b[op[j]] ^= 1;
continue;
}
int ok = 0;
for(int x = l; x <= r; x++) {
ok += b[x];
}
if(ok == r - l + 1) {
ans += 1;
}
}
cout << ans << "\n";
}
else {
int index;
cin >> index;
op[i] = index;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |