#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 |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
220 ms |
1208 KB |
Output is correct |
2 |
Correct |
240 ms |
1360 KB |
Output is correct |
3 |
Correct |
265 ms |
1360 KB |
Output is correct |
4 |
Correct |
256 ms |
3820 KB |
Output is correct |
5 |
Correct |
319 ms |
4052 KB |
Output is correct |
6 |
Correct |
225 ms |
3712 KB |
Output is correct |
7 |
Correct |
491 ms |
3564 KB |
Output is correct |
8 |
Correct |
494 ms |
5104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |