#include <bits/stdc++.h>
using namespace std;
vector<int> r;
int n, k;
void init(int kk, std::vector<int> rr) {
r = rr;
n = r.size();
k = kk;
}
bool valid(const vector<int>& h) {
for (int i = 0; i < n; ++i) {
int cnt = 0;
for (int j = 1; j < k; ++j) {
int idx = (i + j) % n;
if (h[idx] > h[i]) cnt++;
}
if (cnt != r[i]) return false;
}
return true;
}
int compare_plants(int x, int y) {
int gt = 0, lt = 0;
vector<int> h(n);
for (int i = 0; i < n; ++i) h[i] = i + 1; // heights from 1 to n
do {
if (valid(h)) {
if (h[x] > h[y]) gt = 1;
if (h[x] < h[y]) lt = 1;
}
} while (next_permutation(h.begin(), h.end()));
if (gt && !lt) return 1;
if (!gt && lt) return -1;
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... |