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>
using namespace std;
char opposite(char c) {
if(c=='0')
return '1';
return '0';
}
bool ok(string str, int a, int b) {
for(int i = a-1; i < b-1; i++) {
if(str[i]=='0')
return 0;
}
return 1;
}
int main() {
int n, q;
cin >> n >> q;
vector<string> states;
string str;
cin >> str;
states.push_back(str);
for(int i = 0; i < q; i++) {
string type;
int a, b;
cin >> type >> a;
if(type=="toggle") {
str[a-1] = opposite(str[a-1]);
} else {
cin >> b;
int ans = 0;
for(auto i: states)
ans+=ok(i, a, b);
cout << ans << '\n';
}
states.push_back(str);
}
}
# | 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... |