#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n, q;
cin >> n >> q;
string S;
cin >> S;
vector<int> started(n+1, -1);
vector<int> res(n+1, 0);
for(int i = 1; i <= n; i++)
{
if(S[i-1] == '1') started[i] = 0;
}
int A, B;
for(int i = 1; i <= q; i++)
{
cin >> S;
if(S == "toggle")
{
cin >> A;
if(started[A] == -1) started[A] = i;
else
{
res[A] += i - started[A];
started[A] = -1;
}
}
else
{
cin >> A >> B;
cout << res[A] + (started[A] != -1 ? i - started[A] : 0) << '\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
668 ms |
1332 KB |
Output is correct |
2 |
Correct |
687 ms |
1304 KB |
Output is correct |
3 |
Correct |
738 ms |
1368 KB |
Output is correct |
4 |
Correct |
870 ms |
8916 KB |
Output is correct |
5 |
Correct |
922 ms |
9492 KB |
Output is correct |
6 |
Correct |
746 ms |
8724 KB |
Output is correct |
7 |
Correct |
1240 ms |
9916 KB |
Output is correct |
8 |
Correct |
1257 ms |
11220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |