#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include "plants.h"
using namespace std;
using ll = long long;
const int inf = 1e9;
#define debug(args...) cout << "[" << #args << "]: "; debug_out(args);
void debug_out() {
cout << endl;
}
template<typename H, typename... T>
void debug_out(H h, T... t) {
cout << h << ", ";
debug_out(t...);
}
void vis() {
int n = 7;
int k = 4;
vector<int> arr(n);
iota(arr.begin(), arr.end(), 1);
map<vector<int>, vector<int>> mp;
do {
vector<int> r;
for (int i = 0; i < n; i++) {
int cnt = 0;
for (int j = i; j < i + k; j++)
cnt += arr[j % n] > arr[i];
r.push_back(cnt);
}
mp[r] = arr;
}while (next_permutation(arr.begin(), arr.end()));
for (auto[r, arr] : mp) {
for (int i : r) cout << i << ' ';
cout << "= ";
for (int i : arr) cout << i << ' ';
cout << endl;
}
return;
}
int n;
vector<int> p;
void init(int k, std::vector<int> r) {
n = r.size();
p.resize(n);
vector<int> done(n);
int cur = n;
for (int i = 0; i < n; i++) {
if (done[i]) continue;
bool ok = r[i] == 0;
for (int j = i - k + 1; j < i; j++) {
int jj = (j+n) % n;
if (done[jj]) continue;
ok &= r[jj] > 0;
}
if (ok) {
for (int j = i - k + 1; j < i; j++) {
int jj = (j+n) % n;
if( done[jj]) continue;
r[(j + n) % n]--;
}
p[i] = cur--;
done[i] = 1;
i = -1;
}
}
}
int compare_plants(int x, int y) {
return p[x] < p[y] ? -1 : 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
871 ms |
352 KB |
Output is correct |
7 |
Execution timed out |
4019 ms |
2644 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
871 ms |
352 KB |
Output is correct |
7 |
Execution timed out |
4019 ms |
2644 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
62 ms |
3048 KB |
Output is correct |
4 |
Execution timed out |
4046 ms |
5732 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |