#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));
v.pb(v[0]+n);
REP(i,SZ(v)-1){
if(v[i+1]>=v[i]+k) return v[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);
vis[t] = 1;
a[t] = n-T;
REP(i,k-1){
int pre = (t-1-i+n)%n;
if(!vis[pre]) r[pre]--;
}
}
// 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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
12 ms |
384 KB |
Output is correct |
7 |
Correct |
329 ms |
3192 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
12 ms |
384 KB |
Output is correct |
10 |
Correct |
314 ms |
3320 KB |
Output is correct |
11 |
Correct |
316 ms |
3192 KB |
Output is correct |
12 |
Correct |
185 ms |
3448 KB |
Output is correct |
13 |
Correct |
370 ms |
3196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
12 ms |
384 KB |
Output is correct |
7 |
Correct |
329 ms |
3192 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
12 ms |
384 KB |
Output is correct |
10 |
Correct |
314 ms |
3320 KB |
Output is correct |
11 |
Correct |
316 ms |
3192 KB |
Output is correct |
12 |
Correct |
185 ms |
3448 KB |
Output is correct |
13 |
Correct |
370 ms |
3196 KB |
Output is correct |
14 |
Correct |
3377 ms |
3508 KB |
Output is correct |
15 |
Execution timed out |
4067 ms |
5316 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Runtime error |
1 ms |
512 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |