#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
const int M = 5005 ;
int n;
int chosen;
vector<int> h(M,0);
void init(int k, vector<int> r) {
n = r.size();
vector<bool> vis(M,0);
auto ind = [&](int x){
return (x+n)%n;
};
auto other = [&](int x){
for(int i=1;i<k;i++){
//cerr<<i<<" "<<ind(x-i) << '\n';
if(r[ind(x-i)] == 0){
return false;
}
}
return true;
};
auto clean = [&](int x){
for(int i=0;i<k;i++){
//cerr<<i<<" "<<ind(x-i) << ' ';
r[ind(x-i)]--;
}//cerr<<endl;
};
int nxt = n;
int cnt = n;
while(cnt--){
for(int i=0;i<n;i++){
if(vis[i])continue;
if(r[i] == 0){
//cerr<<i<<endl;
if(other(i)){
//cerr<<i<<endl;
vis[i] = 1;
h[i] = nxt--;
clean(i);
break;
}
}
}
}/*
for(auto i:order)cerr << i<<" ";
cerr<<'\n';
*/
return;
}
int compare_plants(int x, int y) {
if(h[x] > h[y])return 1;
if(h[y] > h[x])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 |
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 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
15 ms |
416 KB |
Output is correct |
7 |
Correct |
378 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
20 ms |
416 KB |
Output is correct |
10 |
Correct |
362 ms |
4972 KB |
Output is correct |
11 |
Correct |
242 ms |
4932 KB |
Output is correct |
12 |
Correct |
266 ms |
5100 KB |
Output is correct |
13 |
Correct |
439 ms |
4976 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
6 |
Correct |
15 ms |
416 KB |
Output is correct |
7 |
Correct |
378 ms |
5076 KB |
Output is correct |
8 |
Correct |
3 ms |
332 KB |
Output is correct |
9 |
Correct |
20 ms |
416 KB |
Output is correct |
10 |
Correct |
362 ms |
4972 KB |
Output is correct |
11 |
Correct |
242 ms |
4932 KB |
Output is correct |
12 |
Correct |
266 ms |
5100 KB |
Output is correct |
13 |
Correct |
439 ms |
4976 KB |
Output is correct |
14 |
Incorrect |
1601 ms |
5416 KB |
Output isn't correct |
15 |
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 |
71 ms |
4836 KB |
Output is correct |
4 |
Runtime error |
75 ms |
11240 KB |
Execution killed with signal 11 |
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 |
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 |
312 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 |
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 |
- |