#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=300+10;
int all[maxn],tr[maxn],res[maxn][maxn],fake[maxn];
int k,n;
void init(int k_, std::vector<int> r) {
k=k_;
n=(int)r.size();
for(int i=0;i<n;i++){
all[i]=r[i];
}
for(int x=0;x<n;x++){
vector<int>nago;
for(int i=0;i<n;i++){
fake[i]=all[i];
}
for(int i=0;i<n;i++){
vector<int>tof;
int vis1=0;
for(int j=0;j<n;j++){
if(fake[j]==0){
tof.push_back(j);
}
}
vector<int>tofy;
for(int j=(int)tof.size()-1;j>0;j--){
if(tof[j]-tof[j-1]>=k){
tofy.push_back(tof[j]);
if(tof[j]==x){
vis1=1;
}
}
}
if((tof[0]-tof.back()+n)%n>=k||(int)tof.size()==1){
tofy.push_back(tof[0]);
if(tof[0]==x){
vis1=1;
}
}
while((int)tofy.size()>0&&(tofy.back()==x)){
tofy.pop_back();
}
if((int)tofy.size()==0){
for(int j=0;j<n;j++){
if(nago[j]==0){
res[x][j]=1;
}
}
break;
}
nago[tofy.back()]=1;
if(vis1){
res[x][tofy.back()]=2;
}
for(int h=1;h<=k-1;h++){
fake[(tofy.back()-h+n)%n]--;
}
fake[tofy.back()]=-1;
}
}
}
int compare_plants(int x, int y) {
if(res[x][y]==2||res[y][x]==2){
return 0;
}
if(res[x][y]==1){
return 1;
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |