#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 300001;
const int INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
int a[NMAX];
string s[NMAX];
int qa[NMAX];
int qb[NMAX];
int total[NMAX];
int lst[NMAX];
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, i, q;
cin >> n >> q;
for(i = 1; i <= n; i++){
char c;
cin >> c;
a[i] = c - '0';
}
for(i = 1; i <= q; i++){
cin >> s[i];
cin >> qa[i];
if(s[i][0] == 'q'){
cin >> qb[i];
qb[i]--;
cout << total[qa[i]] + (i - lst[qa[i]]) * (a[qa[i]] == 1) << "\n";
}else{
a[qa[i]] ^= 1;
if(a[qa[i]] == 0){
total[qa[i]] += (i - lst[qa[i]]);
}
lst[qa[i]] = i;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
12636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
15440 KB |
Output is correct |
2 |
Correct |
54 ms |
16980 KB |
Output is correct |
3 |
Correct |
57 ms |
17748 KB |
Output is correct |
4 |
Correct |
67 ms |
21328 KB |
Output is correct |
5 |
Correct |
68 ms |
21840 KB |
Output is correct |
6 |
Correct |
65 ms |
21328 KB |
Output is correct |
7 |
Correct |
79 ms |
19828 KB |
Output is correct |
8 |
Correct |
84 ms |
21332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
12632 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
14684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
12636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |