#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 in_window(int from, int to) {
// Returns true if 'to' is in the next k-1 plants after 'from'
int dist = (to - from + n) % n;
return 1 <= dist && dist <= k-1;
}
int compare_plants(int x, int y) {
if (in_window(x, y)) {
if (r[x] == 0) return 1;
if (r[x] == k-1) return -1;
}
if (in_window(y, x)) {
if (r[y] == 0) return -1;
if (r[y] == k-1) 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... |