# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
304607 | SorahISA | Comparing Plants (IOI20_plants) | C++17 | 4091 ms | 6084 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;
using pii = pair<int, int>;
template<typename T>
using Prior = priority_queue<T>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back
#define debugV(x) cout << #x << " : "; for (auto _ : x) cout << _ << " "; cout << "\n";
int n;
vector<int> val;
void init(int k, vector<int> r) {
n = r.size(), val.assign(n, 0);
for (int i = n; i >= 1; --i) {
vector<int> check;
for (int j = 0; j < n; ++j) {
if (r[j] == 0 and val[j] == 0) check.eb(j);
}
// debugV(check);
int ans = check[0];
for (int j = 0; j < check.size()-1; ++j) {
if (check[j] + k - 1 < check[j+1]) ans = check[j+1];
}
val[ans] = i;
for (int j = 1; j < k; ++j) --r[(ans-j+n)%n];
}
// debugV(val);
return;
}
int compare_plants(int x, int y) {
if (val[x] != val[y]) return val[x] > val[y] ? 1 : -1;
return 0;
}
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... |