#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
int n, q;
cin >> n >> q;
char a[n + 1];
for (int i = 1; i <= n; ++i)
cin >> a[i];
string type[q + 1];
int c[q + 1], d[q + 1];
for (int i = 1; i <= q; ++i) {
cin >> type[i] >> c[i];
if (type[i] == "query")
cin >> d[i];
}
if (n <= 100 && q <= 100) {
bool b[n + 1][q + 1] = {};
for (int j = 1; j <= n; ++j)
b[j][0] = a[j] - '0';
for (int i = 1; i <= q; ++i) {
if (type[i] == "toggle") {
if (a[c[i]] == '1')
a[c[i]] = '0';
else
a[c[i]] = '1';
}
for (int j = 1; j <= n; ++j)
b[j][i] = a[j] - '0';
if (type[i] == "query") {
int ans = 0;
for (int j = 0; j < i; ++j) {
bool flag = 1;
for (int z = c[i]; z < d[i]; ++z)
flag &= (b[z][j]);
ans += flag;
}
cout << ans << '\n';
}
}
continue;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
13972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
47 ms |
13972 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |