/**
* 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 |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
1252 KB |
Output is correct |
2 |
Correct |
58 ms |
4692 KB |
Output is correct |
3 |
Correct |
69 ms |
5332 KB |
Output is correct |
4 |
Correct |
66 ms |
7648 KB |
Output is correct |
5 |
Correct |
70 ms |
8288 KB |
Output is correct |
6 |
Correct |
63 ms |
7648 KB |
Output is correct |
7 |
Correct |
99 ms |
8428 KB |
Output is correct |
8 |
Correct |
81 ms |
9860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |