#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n, q;
string s;
cin >> n >> q >> s;
vector<int> cnt(n), l(n);
for (int z = 1; z <= q; z++) {
string t;
cin >> t;
if (t == "toggle") {
int i;
cin >> i; i--;
if (s[i] == '0') s[i] = '1';
else {
cnt[i] += z - l[i];
s[i] = '0';
}
l[i] = z;
}
else {
int a, b;
cin >> a >> b; a--; b--;
cout << cnt[a] + (s[a] == '1' ? z - l[a] : 0) << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
41 ms |
1292 KB |
Output is correct |
2 |
Correct |
46 ms |
4696 KB |
Output is correct |
3 |
Correct |
47 ms |
5200 KB |
Output is correct |
4 |
Correct |
58 ms |
8936 KB |
Output is correct |
5 |
Correct |
57 ms |
9464 KB |
Output is correct |
6 |
Correct |
51 ms |
8676 KB |
Output is correct |
7 |
Correct |
64 ms |
9680 KB |
Output is correct |
8 |
Correct |
69 ms |
10980 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 |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |