#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define nd '\n'
using namespace std;
vector <int> prefix;
ll n=0;
void init (int k, vector <int> r){
n = r.size();
prefix.assign(n,0);
prefix[0]=r[0];
for (ll i=1; i<n; i++){
prefix[i] = prefix[i-1] + r[i];
}
return;
}
int compare_plants(int x, int y){
ll c = prefix[y-1];
if (x != 0) c-=prefix[x-1];
if (c == y-x) return -1;
else if (c == 0) return 1;
c = prefix[n-1] - prefix[y-1];
c+= prefix[x-1];
if (c == n-y+x) return 1;
else if (c == 0) return -1;
return 0;
}
int main (){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
init(2, {0,1,0,1});
cout << compare_plants(0,3) << nd;
cout << compare_plants(1, 3) << nd;
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccHY0aXY.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1VuXZ0.o:plants.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status