#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[MAXN];
int pref[MAXN];
signed main() {
fastInp;
int n, q;
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> c[i];
pref[i] = (c[i] == '1');
}
string type;
for (int xod = 1, tiktak = 1; xod <= q; xod++, tiktak++) {
cin >> type;
if (type == "query") {
int l, r;
cin >> l >> r;
assert(l + 1 == r);
cout << pref[l] << endl;
}
if (type == "toggle") {
int pos;
cin >> pos;
c[pos] = (c[pos] == '1' ? '0' : '1');
}
for (int i = 1; i <= n; i++) {
if (c[i] == '1') {
pref[i]++;
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
502 ms |
4460 KB |
Output is correct |
2 |
Correct |
647 ms |
4964 KB |
Output is correct |
3 |
Execution timed out |
5089 ms |
5276 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
492 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |