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;
using ll = long long;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, q;
string s;
cin >> n >> q >> s;
vector<int> cnt(n), l(n);
for (int z = 1; z <= q; z++) {
string t;
cin >> t;
if (t == "toggle") {
int i;
cin >> i; i--;
if (s[i] == '0') s[i] = '1';
else {
cnt[i] += z - l[i];
s[i] = '0';
}
l[i] = z;
}
else {
int a, b;
cin >> a >> b; a--; b--;
cout << cnt[a] + (s[a] == '1' ? z - l[a] : 0) << '\n';
}
}
}
# | 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... |