#include <bits/stdc++.h>
#define nl '\n'
#ifdef LOCAL
#include "template/debug.hpp"
#else
#define dbg(...) ;
#define timer(...) ;
#endif
signed main() {
#ifndef LOCAL
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
#endif
int n, q;
std::cin >> n >> q;
std::string s;
std::cin >> s;
std::vector<int> ans(n);
for (int i = 1; i <= q; i++) {
std::string com;
std::cin >> com;
if (com == "toggle") {
int id;
std::cin >> id;
--id;
if (s[id] == '0') {
ans[id] -= i;
} else {
ans[id] += i;
}
s[id] = '1' ^ '0' ^ s[id];
} else {
int a, b;
std::cin >> a >> b;
--a, --b;
if (s[a] == '0') {
std::cout << ans[a] << nl;
} else {
std::cout << ans[a] + i << nl;
}
}
}
}
/*
5 7
11011
query 3 4
toggle 3
query 3 4
query 1 2
toggle 1
query 3 4
query 1 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
61 ms |
4436 KB |
Output is correct |
2 |
Correct |
62 ms |
4688 KB |
Output is correct |
3 |
Correct |
58 ms |
5200 KB |
Output is correct |
4 |
Correct |
71 ms |
7736 KB |
Output is correct |
5 |
Correct |
72 ms |
8320 KB |
Output is correct |
6 |
Correct |
64 ms |
7396 KB |
Output is correct |
7 |
Correct |
92 ms |
8420 KB |
Output is correct |
8 |
Correct |
80 ms |
9944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |