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>
#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
*/
# | 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... |