# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
359958 | Sorting | Comparing Plants (IOI20_plants) | C++17 | 65 ms | 4984 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 N = 2e5 + 3;
int r[N], p[N], k, n;
void init(int _k, vector<int> _r) {
k = _k;
n = _r.size();
for(int i = 0; i < _r.size(); ++i)
r[i] = _r[i];
for(int i = n - 1; i >= 0; --i){
int prev = n, idx;
bool ok = false;
for(int j = n - 1; j >= 0; --j){
if(prev - j >= k && prev != n){
idx = prev;
ok = true;
break;
}
if(!r[j]) prev = j;
}
if(!ok){
for(int j = n - 1; j >= 0; --j)
if(!r[j]){
idx = j;
break;
}
}
p[idx] = i;
r[idx] = n;
for(int j = 1; j <= k - 1; ++j)
r[(idx - j + n) % n]--;
}
}
int compare_plants(int x, int y) {
return (p[x] > p[y]) ? 1 : -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... |