#include "plants.h"
#include "bits/stdc++.h"
using namespace std;
vector<int> a;
int n;
void init(int k, vector<int> r) {
n = r.size();
a.resize(n);
for(int i=n;i>0;i--){
//~ for(int i=0;i<n;i++) cout<<r[i]<<" ";
//~ cout<<"\n";
int cnt = 0;
for(int i=0;i<k - 1;i++) cnt += (r[i] == 0);
int p = -1;
for(int i=k - 1;;){
if(!cnt && r[i] == 0){
p = i;
break;
}
cnt -= (r[(i + n - k + 1) % n] == 0);
i = (i + 1) % n;
if(i == k - 1) break;
}
assert(~p);
//~ cout<<i<<endl;
r[p] = n + 1;
a[p] = i;
for(int i=0;i<n;i++){
if((i <= p && p < i + k) || (i <= p + n && p + n < i + k)){
r[i]--;
}
}
}
//~ for(int i=0;i<n;i++) cout<<a[i]<<" ";
//~ cout<<"\n";
return;
}
int compare_plants(int x, int y) {
if(a[x] > a[y]) return 1;
if(a[x] < a[y]) return -1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |