#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 |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5077 ms |
248068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8192 KB |
Output is correct |
2 |
Correct |
67 ms |
8192 KB |
Output is correct |
3 |
Correct |
143 ms |
8312 KB |
Output is correct |
4 |
Correct |
234 ms |
8308 KB |
Output is correct |
5 |
Runtime error |
320 ms |
524292 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
8312 KB |
Output is correct |
2 |
Correct |
194 ms |
8192 KB |
Output is correct |
3 |
Correct |
136 ms |
8192 KB |
Output is correct |
4 |
Correct |
21 ms |
8192 KB |
Output is correct |
5 |
Runtime error |
295 ms |
524292 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Execution timed out |
5077 ms |
248068 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |