#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 4;
int n, pre[N];
void init(int k, std::vector<int> r) {
assert(k == 2);
n = r.size();
for (int i=1; i<=n; i++) pre[i] = pre[i-1] + r[i-1];
return;
}
int compare_plants(int x, int y) {
if (x==y) return 0;
if (x<y) {
int p = pre[y]-pre[x]; int q = pre[n]-p;
if (p == y-x || q == n-y+x) return 1;
else if (!p || !q) return -1;
else return 0;
}
else {
int p = pre[x]-pre[y]; int q = pre[n]-p;
if (!p || !q) return 1;
else if (p == x-y || q == n-x+y) return 1;
else 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... |