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 <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
signed main() {
#ifdef PC
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> n >> q;
vector<vector<int>> was(q + 1, vector<int> (n, 0));
for (int i = 0; i < n; i++) {
char c;
cin >> c;
was[0][i] = (c - '0');
}
for (int i = 0; i < q; i++) {
was[i + 1] = was[i];
string s;
cin >> s;
if(s == "toggle") {
int id;
cin >> id;
id--;
was[i + 1][id] = !was[i + 1][id];
continue;
}
int l, r, ans = 0;
cin >> l >> r;
l--, r--;
for (int j = 0; j <= i; j++) {
int fl = 1;
for (int z = l; z < r; z++) {
if(!was[j][z])
fl = 0;
}
ans += fl;
}
cout << ans << '\n';
}
}
# | 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... |