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 "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int n;
int sled[maxn]; // 1 = veci
int pref[maxn];
int uk=0;
void init(int k, vector<int> r) {
n=r.size();
for(int i=0;i<n;i++){
if(r[i]==1) sled[i]=1;
if(i>0) pref[i]=pref[i-1];
pref[i]+=sled[i];
uk+=sled[i];
}
return;
}
int qry(int l,int r){
return pref[r]-(l>0 ? pref[l-1]:0);
}
int compare_plants(int x, int y){
if(qry(x,y-1)==y-x) return -1;
int ostalo=uk-qry(x,y-1);
if(ostalo==n-y+x) return 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |