#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int ans[5010];
vector<int> r;
int dis (int i, int j) {
if (i == -1e9 or j == -1e9) return -1e9;
return (j-i+n) % n;
}
void init(int k, vector<int> R) {
r = R;
n = r.size();
int lev = 0;
int cnt = 0;
while (cnt < n) {
int last = -1e9;
queue<int> c;
for (int i = 0; i < n; i++) {
if (r[i] == 0) {
if (dis(last, i) < k) {
lev++;
}
ans[i] = lev;
r[i] = -1;
c.push(i);
// cerr << i << ' ' << lev << endl;
last = i;
cnt++;
}
}
while (!c.empty()) {
auto t = c.front(); c.pop();
for (int i = 1; i < k; i++) {
int ind = (t-i+n) % n;
// cerr << "- " << ind << endl;
r[ind]--;
}
}
lev++;
}
return;
}
int compare_plants(int x, int y) {
if (ans[x] > ans[y]) return -1;
if (ans[x] < ans[y]) return 1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Execution timed out |
4075 ms |
204 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Execution timed out |
4051 ms |
204 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
292 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |