#include "plants.h"
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f0r(i,n) for(int i = 0; i<n; i++)
#define FOR(i, k, n) for(int i = k; i<n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vb vector<bool>
#define vout(v) for(auto u : v)cout<<u<<' '; cout<<'\n';
#define dout(x) cout<<x<<' '<<#x<<'\n';
using namespace std;
int n;
vi v;
int k;
vi ps;
int sum(int l, int r){
	int thing, len;
	if(l <= r){
		thing = ps[r+1] - ps[l];
		len = r - l + 1;
	}
	else{
		//sum from r + 1 to l - 1
		thing = ps[l] - ps[r+1];
		len = l - r - 1;
	}
	if(thing == len)return 1;
	if(thing == 0)return 0;
	return -1;
}
void init(int k, std::vector<int> r) {
	v = r;
	n = r.size();
	::k=k;
	ps.resize(n+1);
	FOR(i, 1, n+1){
		ps[i] = ps[i-1] + r[i-1];
	}
}
int compare_plants(int x, int y) {
	//path from x to y is all 1, means y is taller, return -1
	int rhs = (x == 0) ? n-1 : x-1;
	if(sum(x, y-1) == 1){
		return -1;
	}
	else if(sum(x, y-1) == 0){
		return 1;
	}
	else if(sum(y, rhs) == 1){
		return 1;
	}
	else if(sum(y, rhs) == 0){
		return -1;
	}
	else return 0;
	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... |