#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;
int maxdiff = 0;
int ltog = 0, fque = 1e9;
for(int i = 1; i <= q; i++)
{
cin >> queries[i].first;
if(queries[i].first == "toggle")
{
cin >> queries[i].second.first;
ltog = i;
} else {
cin >> queries[i].second.first >> queries[i].second.second;
maxdiff = max(maxdiff, queries[i].second.second - queries[i].second.first);
fque = min(fque, i);
}
}
if(max(n, q) <= 0) // 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
{
if(maxdiff == 1) // Subtask 2
{
vector<int> roads(n+5, 0);
vector<int> last(n+5, 0);
for(int i = 1; i <= q; i++)
{
int idx = queries[i].second.first;
if(queries[i].first == "toggle")
{
if(in[idx] == '1')
{
roads[idx] += i - last[idx];
in[idx] = '0';
} else
{
last[idx] = i;
in[idx] = '1';
}
} else
{
int val = roads[idx];
if(in[idx] == '1')
{
val += i - last[idx];
}
cout << val << "\n";
}
}
} else if(ltog < fque) // Subtask 4
{
} else
{
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
21332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
172 ms |
22736 KB |
Output is correct |
2 |
Correct |
180 ms |
25792 KB |
Output is correct |
3 |
Correct |
210 ms |
26392 KB |
Output is correct |
4 |
Correct |
245 ms |
30064 KB |
Output is correct |
5 |
Correct |
243 ms |
30580 KB |
Output is correct |
6 |
Correct |
231 ms |
30068 KB |
Output is correct |
7 |
Correct |
295 ms |
30976 KB |
Output is correct |
8 |
Correct |
297 ms |
32248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
21332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
21388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
21332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |