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;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, q; cin >> n>> q;
string s; cin >> s;
vector<string> time(q + 1);
time[0] = s;
for (int i = 0; i < q; ++i) {
string t; cin >> t;
string newTime = time[i];
time[i + 1] = newTime;
if (t == "toggle") {
int a; cin >> a;
a--;
newTime[a] = time[i][a] == '1' ? '0' : '1';
time[i + 1] = newTime;
} else {
int a, b; cin >> a >> b;
a--;
b--;
int ans = 0;
for (int j = 0; j <= i; ++j) {
bool imp = false;
for (int k = a; k <= b; ++k) {
if (time[j][k] == '0') imp = true;
}
if (!imp) ans += 1;
}
cout << ans << "\n";
}
}
return 0;
}
# | 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... |