/**
* In the name of Allah
* We are nothing and you're everything
* author: najmuddin
**/
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
#define int ll
const char nl = '\n';
const int N = 101;
int g[N][N];
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q; cin >> n >> q;
string s; cin >> s;
s = '&'+s;
while (q--) {
string tp; cin >> tp;
for (int i = 1; i <= n; ++i) {
for (int j = i+1; j <= n+1; ++j) {
bool ok = true;
for (int k = i; k < j; ++k) {
if (s[k] == '0')ok = false;
if (!ok)break;
}
if (ok)g[i][j] += 1;
}
}
if (tp == "query") {
int u, v; cin >> u >> v;
cout << g[u][v] << nl;
} else {
int i; cin >> i;
if (s[i] == '1')s[i] = '0';
else s[i] = '1';
}
}
return 0;
}
# | 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... |