# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1031912 | KasymK | Street Lamps (APIO19_street_lamps) | C++17 | 1426 ms | 4592 KiB |
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"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int MOD = 1e9+7;
const int N = 1e2+5;
int par[N], ans[N][N];
int main(){
// freopen("file.txt", "r", stdin);
int n, q;
scanf("%d%d", &n, &q);
string s;
cin >> s;
for(int i = 0; i < n; ++i)
par[i+1] = par[i]+(s[i]-'0');
for(int i = 0; i < n; ++i)
for(int j = i+1; j <= n; ++j)
ans[i][j] = (par[j]-par[i] == j-i);
while(q--){
string t;
cin >> t;
if (t == "query"){
int a, b;
scanf("%d%d", &a, &b), a--, b--;
printf("%d\n", ans[a][b]);
}
else{
int i;
scanf("%d", &i), i--;
s[i] = (s[i] == '0' ? '1' : '0');
}
par[0] = 0;
for(int i = 0; i < n; ++i)
par[i+1] = par[i]+(s[i]-'0');
for(int i = 0; i < n; ++i)
for(int j = i+1; j <= n; ++j)
ans[i][j] += (par[j]-par[i] == j-i);
}
return 0;
}
Compilation message (stderr)
# | 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... |