#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 200005;
#define REP(i,n) for(int i=0;i<(n);i++)
#define eb emplace_back
#define pb push_back
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
int n,k;
bool vis[maxn];
int a[maxn];
int find_ans(vector<int> v){
sort(ALL(v));
vector<int> tmp=v;
for(int i:v) tmp.pb(i+n);
REP(i,SZ(tmp)-1){
if(tmp[i+1]-tmp[i]>=n/2) return tmp[i+1]%n;
}
assert(0);
return -1;
}
void init(int _k, std::vector<int> r) {
n = r.size();
k = _k;
assert(k*2>n);
REP(T,n){
// cout<<"T: "<<T<<endl;
vector<int> idx;
REP(j,n) if(!vis[j]){
if(r[j]==0) idx.pb(j);
}
// for(int i:idx) cout<<i<<' ';
// cout<<'\n';
int t = find_ans(idx);
a[t] = n-T;
REP(i,k-1){
int pre = (t-1-i+n)%n;
r[pre]--;
}
vis[t] = 1;
}
// REP(i,n) cout<<a[i]<<" \n"[i==n-1];
return;
}
// bool between(int idx,int l,int r){
// if(l<=idx&&idx<r) return 1;
// if(l<=idx+n&&idx+n<r) return 1;
// // cout<<idx<<' '<<l<<' '<<r<<endl;
// return 0;
// }
int compare_plants(int x, int y) {
// if(between(y,x,x+k)){
// if(v[x]==0) return 1;
// else if(v[x] == k-1) return -1;
// }
// if(between(x,y,y+k)){
// if(v[y]==0) return -1;
// else if(v[y] == k-1) return 1;
// }
// return 0;
if(a[x]>a[y]) return 1;
else if(a[y]>a[x]) return -1;
else return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |