This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: hashman
* created:
**/
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector<int> num(n);
for (int i = 0; i < n; i++) {
num[i] += s[i] - '0';
}
for (int i = 0; i < q; i++) {
string op;
cin >> op;
if (op == "query") {
int a, b;
cin >> a >> b;
int ans = num[--a];
if (s[a] == '1') {
ans += i;
}
cout << ans << '\n';
} else {
int lamp;
cin >> lamp;
lamp--;
s[lamp] = '1' + '0' - s[lamp];
if (s[lamp] == '1') {
num[lamp] -= i;
} else {
num[lamp] += i;
}
}
}
}
// Cute is justice!
# | 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... |