#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
typedef pair<int, bool> pii;
int n, q;
pii last[maxn];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin >> n >> q;
for(int i=1; i<=n; i++){
char a;
cin >> a;
last[i] = {0, bool(a-'0')};
}
for(int t=1; t<=q; t++){
string op;
cin >> op;
if(op[0] == 'q'){
int a, b;
cin >> a >> b;
bool ok = true;
int ans = 0;
for(int i=a; i<b; i++){
if(!last[i].second) ok = false;
ans = max(ans, last[i].first);
}
if(!ok) cout << 0 << endl;
else cout << t-ans << endl;
}
else{
int i;
cin >> i;
last[i].first = t, last[i].second ^= 1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
465 ms |
4256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
4 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Runtime error |
6 ms |
2296 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |