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 "plants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int ans[5010];
vector<int> r;
void init(int k, vector<int> R) {
r = R;
n = r.size();
int lev = 0;
int cnt = 0;
while (cnt < n) {
queue<int> c;
for (int i = 0; i < n; i++) {
if (r[i] == 0) {
ans[i] = lev;
r[i] = -1;
c.push(i);
// cerr << i << ' ' << lev << endl;
cnt++;
}
}
while (!c.empty()) {
auto t = c.front(); c.pop();
for (int i = 1; i < k; i++) {
int ind = (t-i+n) % n;
// cerr << "- " << ind << endl;
r[ind]--;
}
}
lev++;
}
return;
}
int compare_plants(int x, int y) {
if (ans[x] > ans[y]) return -1;
if (ans[x] < ans[y]) 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... |