//#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> a, sum;
int check1(int x, int y) {
if((x==0&&sum[y-1]==0)||sum[y-1]==sum[x-1])
return 1;
int nxt=sum[n-1]-sum[y-1];
int prv=(x==0?0:sum[x-1]);
if(nxt==n-y&&prv==x)
return 1;
if((x==0&&sum[y-1]==y)||sum[y-1]-sum[x-1]==y-x)
return -1;
nxt=sum[n-1]-sum[y-1];
prv=(x==0?0:sum[x-1]);
if(nxt==0&&prv==0)
return -1;
return 0;
}
int compare_plants(int x, int y) {
if(k==2)
return check1(x,y);
// if(k*2>n)
// return check2(x,y);
}
void init(int K, vector<int> r) {
n=(int)r.size(), k=K, a=r, sum=a, partial_sum(sum.begin(), sum.end(), sum.begin());
}
int main() {
init(2, {0, 1, 0, 1});
cout << compare_plants(1, 3);
return 0;
}
Compilation message
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
29 | }
| ^
/tmp/cco2gU4X.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cchxQe1k.o:plants.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status