#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz size()
#define ff first
#define ss second
#define pb push_back
#define pii pair <int, int>
#define dur exit(0)
#define dur1 return(0)
const int N = 1e2 + 5;
int n, q, dis[N][N];
string s;
int main () {
// freopen ("input.txt", "r", stdin);
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> q >> s;
s = " " + s;
for (int i = 1; i <= n + 1; ++i) {
for (int j = i + 1; j <= n + 1; ++j) {
if (s[j - 1] == '1') {
dis[i][j]++;
}
else {
break;
}
}
}
if (n <= 100 and q <= 100) {
while ( q-- ) {
string typ;
int l, r;
cin >> typ;
if (typ[0] == 'q') {
cin >> l >> r;
cout << dis[l][r] << "\n";
for (int i = 1; i <= n + 1; ++i) {
for (int j = i + 1; j <= n + 1; ++j) {
if (s[j - 1] == '1') {
dis[i][j]++;
}
else {
break;
}
}
}
}
else {
cin >> l;
s[l] = (s[l] == '1' ? '0' : '1');
for (int i = 1; i <= n + 1; ++i) {
for (int j = i + 1; j <= n + 1; ++j) {
if (s[j - 1] == '1') {
dis[i][j]++;
}
else {
break;
}
}
}
}
}
}
}
# | 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... |