#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
using namespace std;
const int N = 300010;
int n, q, a, b, ch[N], curr[N], lst[N];
string ipt, tmp;
void solve () {
cin >> n >> q >> ipt;
for (int i = 1; i <= q; i++) {
cin >> tmp;
if (tmp[0] == 't') {
cin >> a;
ch[i] = a;
if (ipt[a-1] == '0') {
lst[a] = i;
ipt[a-1] = '1';
}
else {
curr[a] += i - lst[a];
ipt[a-1] = '0';
}
}
else {
cin >> a >> b;
if (ipt[a-1] == '1') cout << i - lst[a] + curr[a] << "\n";
else cout << curr[a] << "\n";
}
}
}
signed main() {IOS solve(); return 0;}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |