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 v[300005],n,q,x,y,ult[300005],nr[300005],i,j,t;
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(0);
#ifdef HOME
ifstream cin("date.in");
ofstream cout("date.out");
#endif // HOME
cin>>n>>q;
for (i=1;i<=n;i++)
{
char ch;
cin>>ch;
v[i]=ch-'0';
nr[i]=v[i];
ult[i]=1;
}
for (i=1;i<=q;i++)
{
char tip[15];
cin>>tip;
if (strcmp(tip,"query")==0)
{
cin>>x>>y;
if (v[x]==1)
{
cout<<nr[x]+i-ult[x]<<'\n';
}
else
cout<<nr[x]<<'\n';
}
else
{
cin>>x;
if (v[x]==1)
{
nr[x]=nr[x]+i-ult[x];
}
ult[x]=i;
v[x]=1-v[x];
}
}
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... |