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 M = 200005;
int pref[M];
int n;
int sum(int l,int r){
//cerr << l <<" "<<r<<endl;
if(r < l){
return sum(0,r)+sum(l,n-1);
}
return pref[r+1]-pref[l];
}
void init(int k, vector<int> r) {
n = r.size();
for(int i=0;i<n;i++){
pref[i+1] = pref[i]+r[i];
}
return;
}
bool istaller(int x,int y){
//cerr <<sum(x,(y > 0 ? y-1 : n-1))<<" "<<x<<" "<<(y > 0 ? y-1 : n-1)<<" "<<endl;
if(sum(x,(y > 0 ? y-1 : n-1)) == 0)return true;
int range = sum(0,n-1)-sum(x,y);
if(range == n-abs(x-y)-1)return true;
return false;
}
int compare_plants(int x, int y) {
//cerr << 1 << endl;
if(istaller(x,y))return 1;
//scerr << 2 << endl;
if(istaller(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... |