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;
int main()
{
int n,q;
cin>>n>>q;
string s;
cin>>s;
int las[n],su[n]={};
for (int i=0;i<n;i++)
if (s[i]=='1')
las[i]=0;
for (int m=1;m<=q;m++)
{
string t;
cin>>t;
if (t=="toggle")
{
int i;
cin>>i;
i--;
if (s[i]=='0')
{
las[i]=m;
s[i]='1';
}
else
{
su[i]+=m-las[i];
s[i]='0';
}
}
else
{
int a,b;
cin>>a>>b;
a--;
int ans=su[a];
if (s[a]=='1')
ans+=m-las[a];
cout<<ans<<endl;
}
}
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... |