#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;
int n, q;
void task1() {
vector<int> a[105];
auto get = [&](int l, int r, vector<int> a) {
for (int i=l; i<r; i++) {
if (!a[i]) return false;
}
return true;
};
string s; cin>>s;
a[0].resize(n+1);
for (int i=1; i<=n; i++) {
a[0][i]=(s[i-1]-'0');
}
a[1]=a[0];
for (int qq=1; qq<=q; qq++) {
string op; cin>>op;
a[qq+1]=a[qq];
if (op=="query") {
int res=0;
int l,r; cin>>l>>r;
for (int t=1; t<=qq; t++) {
res += get(l,r,a[t]);
}
cout<<res<<"\n";
} else {
//toggle
int i; cin>>i;
a[qq+1][i]=1-a[qq+1][i];
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin>>n>>q;
if (n<=100 && q<=100) task1();
// for (int t=0; t<=q; t++) {
// for (int i=1; i<=n; i++) {
// cout<<a[t][i];
// }
// cout<<endl;
// }
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |