#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(r1), debugV(r2);
// debugV(val1), debugV(val2);
// cout << check1.size() << " " << check2.size() << "\n";
// debugV(check1), debugV(check2);
int sz1 = check1.size(), sz2 = check2.size();
int ans1 = check1[0], ans2 = check2[0];
for (int j = 0; j < sz1; ++j) {
if (check1[j] + k - 1 < check1[(j+1)%sz1]) ans1 = check1[(j+1)%sz1];
}
for (int j = sz2-1; j >= 0; --j) {
if (check2[j] + k - 1 < check2[(j+1)%sz2]) 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), debugV(val2);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
413 ms |
3448 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
418 ms |
3448 KB |
Output is correct |
11 |
Correct |
458 ms |
3320 KB |
Output is correct |
12 |
Correct |
313 ms |
3452 KB |
Output is correct |
13 |
Correct |
482 ms |
3448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
16 ms |
384 KB |
Output is correct |
7 |
Correct |
413 ms |
3448 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
16 ms |
384 KB |
Output is correct |
10 |
Correct |
418 ms |
3448 KB |
Output is correct |
11 |
Correct |
458 ms |
3320 KB |
Output is correct |
12 |
Correct |
313 ms |
3452 KB |
Output is correct |
13 |
Correct |
482 ms |
3448 KB |
Output is correct |
14 |
Execution timed out |
4069 ms |
3064 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
98 ms |
3256 KB |
Output is correct |
4 |
Execution timed out |
4057 ms |
8196 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |