#include "bits/stdc++.h"
using namespace std;
const int MAXN = 3e5+5;
vector< pair<string, pair<int, int> > > queries(MAXN);
string stats[MAXN];
int main()
{
int n, q;
cin >> n >> q;
string in;
cin >> in;
in = " " + in;
stats[0] = in;
for(int i = 1; i <= q; i++)
{
cin >> queries[i].first;
if(queries[i].first == "toggle")
{
cin >> queries[i].second.first;
} else {
cin >> queries[i].second.first >> queries[i].second.second;
}
}
if(max(n, q) <= 100) // Subtask 1
{
for(int i = 1; i <= q; i++)
{
if(queries[i].first == "toggle")
{
in[queries[i].second.first] = (in[queries[i].second.first] == '1' ? '0' : '1');
stats[i] = in;
} else
{
stats[i] = in;
int pos = 0;
for(int ava = 0; ava < i; ava++) {
string temp = stats[ava];
int beg = queries[i].second.first;
int end = queries[i].second.second;
while(beg < end)
{
if(temp[beg] == '1')
beg++;
else
break;
}
if(beg == end)
pos++;
}
cout << pos << "\n";
}
}
} else
{
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
21332 KB |
Output is correct |
2 |
Correct |
12 ms |
21400 KB |
Output is correct |
3 |
Correct |
11 ms |
21360 KB |
Output is correct |
4 |
Correct |
12 ms |
21452 KB |
Output is correct |
5 |
Correct |
12 ms |
21460 KB |
Output is correct |
6 |
Correct |
12 ms |
21460 KB |
Output is correct |
7 |
Correct |
13 ms |
21448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
147 ms |
21332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
21460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
21332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
21332 KB |
Output is correct |
2 |
Correct |
12 ms |
21400 KB |
Output is correct |
3 |
Correct |
11 ms |
21360 KB |
Output is correct |
4 |
Correct |
12 ms |
21452 KB |
Output is correct |
5 |
Correct |
12 ms |
21460 KB |
Output is correct |
6 |
Correct |
12 ms |
21460 KB |
Output is correct |
7 |
Correct |
13 ms |
21448 KB |
Output is correct |
8 |
Incorrect |
147 ms |
21332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |