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 fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
int32_t main(){
fast
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector <string> states;
states.push_back(s);
while(q--) {
string t;
cin >> t;
if(t == "query") {
int a, b, ans = 0;
cin >> a >> b;
for(auto it:states) {
bool yes = 1;
for(int i = a - 1; i < b - 1; i++) {
if(it[i] != '1') {
yes = 0;
break;
}
}
ans += yes;
}
states.push_back(states.back());
cout << ans << "\n";
}
else {
int ind;
cin >> ind;
string p = states.back();
p[ind - 1] = (p[ind - 1] - '0' + 1) % 2 + '0';
states.push_back(p);
}
}
}
# | 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... |