# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403207 | AmineTrabelsi | Street Lamps (APIO19_street_lamps) | C++14 | 4966 ms | 524292 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.
// subtasks will not match always
#include <bits/stdc++.h>
using namespace std;
// Hi
int n,q;
string s;
vector<pair<int,pair<int,int>>> que; // 0 toggle 1 query
void sub_one(){
vector<vector<int>> cnt(n+5,vector<int>(n+5,0));
vector<int> pref(n+5,0);
for(int i=0;i<n;i++){
pref[i+1] = pref[i]+(s[i]=='1');
}
for(int i=0;i<=n;i++){
for(int j=0;j<i;j++){
cnt[i][j] = cnt[j][i] = (pref[i]-pref[j] == i-j);
}
}
for(int tt=0;tt<q;tt++){
if(que[tt].first == 0){
int ind = que[tt].second.first;
if(s[ind] == '0')s[ind] = '1';
else s[ind] = '0';
for(int i=0;i<n;i++){
pref[i+1] = pref[i]+(s[i]=='1');
}
}else{
int a = que[tt].second.first,b = que[tt].second.second;
cout << cnt[a][b] << '\n';
}
# | 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... |