// plants-yanhao-k_large
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> permutation;
void init(int k, std::vector<int> r) {
int n = r.size();
assert(k*2>n);
permutation.resize(n);
for(int i=0; i<n; i++) {
int streak = -n-1;
for(int j=n-1; j>=0; j--) {
if(r[j]==0) {
streak = 0;
} else {
streak++;
}
if(streak==k-1) {
for(int l=j; l<j+k-1; l++) {
r[l]--;
}
r[j+k-1] = 1e6;
permutation[j+k-1] = i;
break;
}
if(j==0) {
for(int l=0; l<=streak; l++) {
r[l]--;
}
for(int l=n-k+streak+1; l<n; l++) {
r[l]--;
}
r[streak] = 1e6;
permutation[streak] = i;
}
}
}
}
int compare_plants(int x, int y) {
return (permutation[x]<permutation[y] ? 1 : -1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 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 |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
127 ms |
3276 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
480 KB |
Output is correct |
10 |
Correct |
154 ms |
3228 KB |
Output is correct |
11 |
Correct |
108 ms |
3192 KB |
Output is correct |
12 |
Correct |
106 ms |
3384 KB |
Output is correct |
13 |
Correct |
123 ms |
3408 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
127 ms |
3276 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
480 KB |
Output is correct |
10 |
Correct |
154 ms |
3228 KB |
Output is correct |
11 |
Correct |
108 ms |
3192 KB |
Output is correct |
12 |
Correct |
106 ms |
3384 KB |
Output is correct |
13 |
Correct |
123 ms |
3408 KB |
Output is correct |
14 |
Correct |
608 ms |
3484 KB |
Output is correct |
15 |
Execution timed out |
4009 ms |
4984 KB |
Time limit exceeded |
16 |
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 |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
360 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 |
288 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 |
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 |
- |