#include <bits/stdc++.h>
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
#define pii pair<int, int>
#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int MAXN = (int)3e5 + 5;
char c[105][105]; // time | string
signed main() {
fastInp;
int n, q;
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> c[0][i];
}
string type;
for (int xod = 1, tiktak = 1; xod <= q; xod++, tiktak++) {
cin >> type;
for (int i = 1; i <= n; i++) {
c[tiktak][i] = c[tiktak - 1][i];
}
if (type == "query") {
int l, r;
cin >> l >> r;
int ans = 0;
for (int t = 0; t < tiktak; t++) {
bool ok = 1;
for (int j = l; j < r; j++) {
ok &= (c[t][j] == '1');
}
ans += ok;
}
cout << ans << endl;
}
if (type == "toggle") {
int pos;
cin >> pos;
c[tiktak][pos] = (c[tiktak][pos] == '1' ? '0' : '1');
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
516 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
492 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
364 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |