# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302857 | Basilhijaz | Comparing Plants (IOI20_plants) | Java | 0 ms | 0 KiB |
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;
vector<int> pre(2000005);
int n;
int cnt = 0;
void init(int k, std::vector<int> r) {
n = r.size();
for(int i = 0; i < n; i++){
pre[i + 1] = pre[i] + r[i];
cnt += r[i];
}
return;
}
int compare_plants(int x, int y) {
if(pre[y] - pre[x] == y - x){
return -1;
}
if(pre[y] - pre[x] == 0){
return 1;
}
if (cnt - (pre[y] - pre[x]) == n - (y - x)){
return 1;
}
else if (cnt - (pre[y] - pre[x]) == 0){
return -1;
}
return 0;
}