#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] << '\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 |
Incorrect |
664 ms |
1288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 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 |
- |