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;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
using ar2 = array<int,2>;
const int mxN = (int)5e3+10;
int n, comp[mxN], COMP;
vector<int> adj[mxN];
int deg[mxN], ord[mxN];
int h[mxN];
void init(int k, vector<int> r) {
n = sz(r); k--; int xd = n;
while(1){
bool ok = 0;
for(int i = 0; i < n; i++){
if(r[i]!=0) continue;
bool bad = 0;
{
int tot = k, j = i;
while(tot-- and !bad){
j--; if(j==-1) j=n-1;
if(r[j]==0) bad=1;
}
}
if(bad) continue;
{
int tot = k, j = i;
while(tot-- and !bad){
j--; if(j==-1) j=n-1;
r[j]--;
}
}
h[i]=xd; xd--; r[i]--; ok=1;
}
if(!ok) break;
}
}
int compare_plants(int x, int y) {
return h[x]>h[y]?1:-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... |