#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];
void init(int _k, std::vector<int> r) {
n = r.size();
k = _k;
// assert(k*2>n);
int pt = 0;
int cnt = 0;
while(cnt<n){
vector<int> idx;
REP(j,n) if(!vis[j]){
if(r[j]==0) idx.pb(j);
}
// for(int i:idx){
// cout<<i<<' ';
// }
// cout<<endl;
idx.pb(idx[0]+n);
REP(i,SZ(idx)-1){
if(idx[i+1]-idx[i]>=k){
int t = idx[i+1]%n;
vis[t] = 1;
cnt++;
a[t] = pt;
REP(j,k-1){
int pre = (t-j-1+n)%n;
if(!vis[pre]) r[pre]--;
}
}
}
pt--;
// for(int i:idx) cout<<i<<' ';
// cout<<'\n';
}
// REP(i,n) cout<<a[i]<<" \n"[i==n-1];
return;
}
int compare_plants(int x, int y) {
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 |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
11 ms |
384 KB |
Output is correct |
7 |
Correct |
315 ms |
3320 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
12 ms |
384 KB |
Output is correct |
10 |
Correct |
330 ms |
3320 KB |
Output is correct |
11 |
Correct |
215 ms |
3140 KB |
Output is correct |
12 |
Correct |
188 ms |
3320 KB |
Output is correct |
13 |
Correct |
393 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
11 ms |
384 KB |
Output is correct |
7 |
Correct |
315 ms |
3320 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
12 ms |
384 KB |
Output is correct |
10 |
Correct |
330 ms |
3320 KB |
Output is correct |
11 |
Correct |
215 ms |
3140 KB |
Output is correct |
12 |
Correct |
188 ms |
3320 KB |
Output is correct |
13 |
Correct |
393 ms |
3320 KB |
Output is correct |
14 |
Correct |
3201 ms |
3504 KB |
Output is correct |
15 |
Execution timed out |
4057 ms |
5428 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
77 ms |
3192 KB |
Output is correct |
4 |
Execution timed out |
4066 ms |
5324 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
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 |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |