This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
#include "plants.h"
#define MAXN 200005
using namespace std;
int pref[MAXN];
int h[MAXN];
int n;
void init(int k, vector<int> r) {
n = r.size();
r.insert(r.begin() + 0, -1);
for (int height = n; height >= 1; height--) {
vector<int> zeroes;
pref[0] = 0;
for (int i = 1; i <= n; i++) {
pref[i] = pref[i-1];
if (r[i] == 0) {
pref[i]++;
zeroes.push_back(i);
}
}
int z = -1;
for (int x : zeroes) {
if (x-k+1 > 0) {
if (pref[x-1] - pref[x-k] == 0) {
z = x;
break;
}
} else {
if (pref[x-1] == 0 && pref[n] - pref[x-k+n] == 0) {
z = x;
break;
}
}
}
r[z] = INT_MAX;
h[z] = height;
for (int i = z-k+1; i < z; i++) {
if (i >= 1) r[i]--;
else r[i + n]--;
}
}
return;
}
int compare_plants(int x, int y) {
if (h[x+1] > h[y+1]) return 1;
else 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... |