#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
int32_t main(){
fast
int n, q;
cin >> n >> q;
string s;
cin >> s;
vector <string> states;
states.push_back(s);
while(q--) {
string t;
cin >> t;
if(t == "query") {
int a, b, ans = 0;
cin >> a >> b;
for(auto it:states) {
bool yes = 1;
for(int i = a - 1; i < b - 1; i++) {
if(it[i] != '1') {
yes = 0;
break;
}
}
ans += yes;
}
states.push_back(states.back());
cout << ans << "\n";
}
else {
int ind;
cin >> ind;
string p = states.back();
p[ind - 1] = (p[ind - 1] - '0' + 1) % 2 + '0';
states.push_back(p);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5089 ms |
6128 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1372 KB |
Output is correct |
2 |
Correct |
6 ms |
1260 KB |
Output is correct |
3 |
Correct |
10 ms |
1372 KB |
Output is correct |
4 |
Correct |
79 ms |
1364 KB |
Output is correct |
5 |
Runtime error |
478 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
1372 KB |
Output is correct |
2 |
Correct |
22 ms |
1400 KB |
Output is correct |
3 |
Correct |
15 ms |
1448 KB |
Output is correct |
4 |
Correct |
1 ms |
1372 KB |
Output is correct |
5 |
Runtime error |
203 ms |
524288 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Execution timed out |
5089 ms |
6128 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |