#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
vi ranking;
void init(int k, std::vector<int> r) {
int n = r.size();
ranking.resize(n);
bool done[n]; memset(done,0,sizeof done);
for(int i = 0; i<n; i++){
int window = 0;
for(int j = 0; j<k; j++){
window+=r[j+1]==0;
r[j]--;
r[j] = max(r[j],0);
}
int j = 0;
if(!done[0]&&window==0) goto found;
for(j = 1;j<n; j++){
window+=r[(j+k-1)%n]==0;
window-=r[j-1]==0;
r[(j+k-1)%n]--;
r[(j+k-1)%n] = max(r[(j+k-1)%n],0);
r[j-1]++;
if(done[j]) continue;
if(window==0) goto found;
}
found:
done[j] = true;
ranking[j] = i;
}
}
int compare_plants(int x, int y) {
if(ranking[x]<ranking[y]) return 1;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |