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>
using namespace std;
vector<int> h;
void init(int k, std::vector<int> r) {
int n = r.size();
h.resize(n);
vector<bool> taken(n);
for(int ht=n;ht;ht--){
for(int i=0;i<n;i++){
if(r[i]!=0)continue;
bool works = true;
int j=i;
for(int len=1;len<k;len++){
j=(j-1+n)%n;
if(r[j]==0)works=false;
}
if(works){
h[i]=ht;
int j=i;
for(int len=1;len<k;len++){
j=(j-1+n)%n;
r[j]--;
}
r[i] = n+1;
break;
} else {
i+=k-1;
}
}
}
}
int compare_plants(int x, int y) {
if(h[x]>h[y])return 1;
else return -1;
}
# | 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... |