# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1029959 | happy_node | Comparing Plants (IOI20_plants) | C++17 | 139 ms | 11980 KiB |
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;
const int MX=5005;
bool vis[MX];
int N;
vector<int> ord, rev;
void init(int k, std::vector<int> r) {
N=r.size();
vector<int> pos;
for(int i=0;i<N;i++)
if(!r[i]) pos.push_back(i);
for(int i=0;i<N;i++) {
int p=-1;
for(int j=0;j+1<pos.size();j++) {
if(pos[j+1]-pos[j]>=k) {
p=pos[j+1];
}
}
if(p==-1) p=pos[0];
ord.push_back(p);
for(int j=0;j<k;j++) {
int np=p-j;
if(np<0) np+=N;
if(vis[np]) continue;
r[np]-=1;
}
vis[p]=1;
vector<int> npos;
for(int j=0;j<N;j++) {
if(vis[j]) continue;
if(r[j]==0) npos.push_back(j);
}
swap(pos,npos);
}
rev.assign(N,0);
for(int i=0;i<N;i++) rev[ord[i]]=i;
}
int compare_plants(int x, int y) {
if(rev[x]<rev[y]) return 1;
return -1;
}
Compilation message (stderr)
# | 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... |