#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n, q; cin >> n>> q;
string s; cin >> s;
vector<string> time(q + 1);
time[0] = s;
for (int i = 0; i < q; ++i) {
string t; cin >> t;
string newTime = time[i];
time[i + 1] = newTime;
if (t == "toggle") {
int a; cin >> a;
a--;
newTime[a] = time[i][a] == '1' ? '0' : '1';
time[i + 1] = newTime;
} else {
int a, b; cin >> a >> b;
a--;
b--;
int ans = 0;
for (int j = 0; j <= i; ++j) {
bool imp = false;
for (int k = a; k <= b; ++k) {
if (time[j][k] == '0') imp = true;
}
if (!imp) ans += 1;
}
cout << ans << "\n";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5052 ms |
19368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
23 ms |
1448 KB |
Output is correct |
3 |
Correct |
44 ms |
1712 KB |
Output is correct |
4 |
Correct |
75 ms |
1368 KB |
Output is correct |
5 |
Runtime error |
875 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
1360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |