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>
#define N 200005
using namespace std;
int pre[2*N];
int revpre[2*N];
int n;
void init(int k, vector<int> r){
n = r.size();
for(int i = 0;i<n;i++){
pre[i] = r[i];
revpre[i] = !r[i];
if(i){
pre[i] += pre[i-1];
revpre[i] += revpre[i-1];
}
}
for(int i = 0;i<n;i++){
pre[i+n] = r[i];
revpre[i+n] = !r[i];
pre[i+n] += pre[i+n-1];
revpre[i+n] += revpre[i+n-1];
}
return;
}
int get(int l,int r){
return pre[r] - (l == 0?0:pre[l-1]);
}
int get2(int l,int r){
return revpre[r] - (l == 0?0:revpre[l-1]);
}
int compare_plants(int x, int y) {
if(get(x,y-1) == 0){
return 1;
}
if(get2(x,y-1) == 0){
return -1;
}
if(get(y,x+n-1) == 0){
return -1;
}
if(get2(y,x+n-1) == 0){
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... |