#include <bits/stdc++.h>
using namespace std;
vector<int> r;
int n;
void init(int k, std::vector<int> rr) {
r = rr;
n = r.size();
}
int check(int from, int to) {
bool all_zero = true;
int x = from;
while (x != (to - 1 + n) % n) {
int next = (x + 1) % n;
if (r[x] != r[next]) {
return 0;
}
if (r[x] != 0) all_zero = false;
x = next;
}
if (all_zero)
return 1;
else
return -1;
}
int compare_plants(int x, int y) {
int res = check(x, y);
if (res != 0) return res;
res = check(y, x);
if (res != 0) return -res;
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... |