#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5+10;
string s;
int n, q, a[maxn], cnt[maxn], t[maxn];
int32_t main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> q >> s;
for(int i = 1; i <= n; i++){
a[i] = (s[i-1] == '1');
t[i] = (a[i] == 1 ? 0 : -1);
}
for(int i = 1; i <= q; i++){
int x, y; cin >> s >> x;
if(s[0]=='t'){
a[x] ^= 1;
if(a[x]) t[x] = i;
else cnt[x] += i - t[x];
}
else cin >> y, cout << cnt[x] + a[x] * (i - t[x]) << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
4408 KB |
Output is correct |
2 |
Correct |
63 ms |
4692 KB |
Output is correct |
3 |
Correct |
59 ms |
5456 KB |
Output is correct |
4 |
Correct |
66 ms |
10020 KB |
Output is correct |
5 |
Correct |
78 ms |
10408 KB |
Output is correct |
6 |
Correct |
67 ms |
9956 KB |
Output is correct |
7 |
Correct |
73 ms |
10600 KB |
Output is correct |
8 |
Correct |
83 ms |
12016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 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 |
- |