This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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[i]+=(i-lst[i]), lst[i]=-1;
}
else
{
cin>>a>>b;
if (lst[a]!=-1) cout<<sm[a]+(i-lst[a])<<'\n';
else cout<<sm[a]<<'\n';
}
}
}
# | 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... |