#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;
break;
}
}
if (!imp) ans += 1;
}
cout << ans << "\n";
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5053 ms |
19932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1368 KB |
Output is correct |
2 |
Correct |
1 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
63 ms |
1352 KB |
Output is correct |
5 |
Runtime error |
335 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1368 KB |
Output is correct |
2 |
Correct |
2 ms |
1372 KB |
Output is correct |
3 |
Correct |
2 ms |
1372 KB |
Output is correct |
4 |
Correct |
1 ms |
1368 KB |
Output is correct |
5 |
Runtime error |
218 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
596 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Execution timed out |
5053 ms |
19932 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |