#include "plants.h"
#include <bits/stdc++.h>
#define fi first
#define se secod
#define sz(x) (int)x.size()
#define cmin(a, b) a=min(a, b)
#define cmax(a, b) a=max(a, b)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
using namespace std;
int n, k;
vector<int> smaller, bigger;
void init(int K, vector<int> r) {
k=K, n=sz(r);
smaller.resize(n, 0), bigger.resize(n, 0);
for (int i=n-1; i<n && r[i]; i=(i+1)%n) smaller[n-1]++;
for (int i=n-1; i<n && !r[i]; i=(i+1)%n) bigger[n-1]++;
for (int i=n-2; i>=0; i--) {
if (r[i]) smaller[i]=smaller[i+1]+1;
else bigger[i]=bigger[i+1]+1;
}
return;
}
int taller(int x, int y) {
int nb=(y-x+n)%n;
if (bigger[x]>=nb) return 1;
swap(x, y);
nb=(y-x+n)%n;
if (smaller[x]>=nb) return 1;
return 0;
}
int compare_plants(int x, int y) {
if (taller(x, y)) return 1;
if (taller(y, x)) 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... |