#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> val1, val2;
void init(int k, vector<int> r1) {
vector<int> r2 = r1;
n = r1.size(), val1.assign(n, 0), val2.assign(n, 0);
for (int i = n; i >= 1; --i) {
vector<int> check1, check2;
for (int j = 0; j < n; ++j) {
if (r1[j] == 0 and val1[j] == 0) check1.eb(j);
if (r2[j] == 0 and val2[j] == 0) check2.eb(j);
}
// debugV(check1);
int sz1 = check1.size(), sz2 = check2.size();
int ans1 = check1[0], ans2 = -1;
for (int j = 0; j < sz1; ++j) {
if (check1[j]+k-1 < check1[(j+1)%sz1]) ans1 = check1[(j+1)%sz1];
}
for (int j = 0; j < sz2; ++j) {
if (check2[j]+k-1 < check2[(j+1)%sz2] and ans2 == -1) ans2 = check2[(j+1)%sz2];
}
val1[ans1] = i, val2[ans2] = i;
for (int j = 1; j < k; ++j) --r1[(ans1-j+n)%n], --r2[(ans2-j+n)%n];
}
// debugV(val1);
return;
}
int compare_plants(int x, int y) {
if (val1[x] > val1[y] and val2[x] < val2[y]) return 0;
if (val1[x] < val1[y] and val2[x] > val2[y]) return 0;
return val1[x] > val1[y] ? 1 : -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |