This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;
int main(){
int n, q;
cin >> n >> q;
vector<int> v(n);
string s;
cin >> s;
for(int i = 0; i < n; i++) v[i] = (s[i] == '1');
vector<vector<int>> ans(n, vector<int>(n));
for(int i = 0; i < q; i++){
for(int j = 0; j < n; j++){
for(int k = j; k < n; k++){
int ok = 1;
for(int a = j; a <= k; a++)
ok &= v[a];
ans[j][k] += ok;
}
}
string t;
cin >> t;
if(t == "toggle"){
int a; cin >> a; a--;
v[a] ^= 1;
}
else{
int l, r; cin >> l >> r; l--, r-= 2;
cout << ans[l][r] << endl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |