#include <bits/stdc++.h>
using namespace std;
const int nx=3e5+5;
int n, q, lst[nx], sm[nx], l, a, b;
string s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>q>>s;
for (int i=1; i<=n; i++) lst[i]=(s[i-1]-'0')-1;
for (int i=1; i<=q; i++)
{
cin>>s;
if (s[0]=='t')
{
cin>>l;
if (lst[l]==-1) lst[l]=i;
else sm[l]+=(i-lst[l]), lst[l]=-1;
}
else
{
cin>>a>>b;
if (lst[a]!=-1) cout<<sm[a]+(i-lst[a])<<'\n';
else cout<<sm[a]<<'\n';
}
}
}
/*
5 7
11111
query 1 2
query 2 3
query 3 4
query 4 5
query 5 6
toggle 1
query 1 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
3440 KB |
Output is correct |
2 |
Correct |
50 ms |
6936 KB |
Output is correct |
3 |
Correct |
58 ms |
7404 KB |
Output is correct |
4 |
Correct |
59 ms |
8880 KB |
Output is correct |
5 |
Correct |
60 ms |
9276 KB |
Output is correct |
6 |
Correct |
53 ms |
8656 KB |
Output is correct |
7 |
Correct |
72 ms |
9444 KB |
Output is correct |
8 |
Correct |
76 ms |
10980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |