This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
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... |