#include <bits/stdc++.h>
using namespace std;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
bool get(int l, int r, vector<int> a) {
for (int i=l; i<r; i++) {
if (!a[i]) return false;
}
return true;
}
int n, q;
vector<int> a[maxn];
bool tog[maxn];
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>q;
string s; cin>>s;
a[0].resize(n+1);
for (int i=1; i<=n; i++) {
a[0][i]=(s[i-1]-'0');
}
for (int qq=1; qq<=q; qq++) {
string op; cin>>op;
a[qq]=a[qq-1];
if (op=="query") {
int res=0;
int l,r; cin>>l>>r;
for (int t=1; t<=qq; t++) {
if (tog[t]) continue;
res += get(l,r,a[t]);
}
cout<<res<<"\n";
} else {
//toggle
int i; cin>>i;
a[qq][i]=1-a[qq][i];
tog[qq]=true;
}
}
// for (int t=0; t<=q; t++) {
// for (int i=1; i<=n; i++) {
// cout<<a[t][i];
// }
// cout<<endl;
// }
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
23808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5055 ms |
33356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
25 ms |
27776 KB |
Output is correct |
2 |
Incorrect |
41 ms |
27768 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
176 ms |
27768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
19 ms |
23808 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |