#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long int lld;
#define trav(a,v) for(auto a:v)
int n;
int K;
int arr[1000000];
int order[1000000];
void init(int k, std::vector<int> r) {
n=r.size();
K=k;
rep(i,0,n)arr[i]=r[i];
if(2*k>n){
rep(i,0,n)order[i]=-1;
int cnt=0;
rep(turn,0,n){
rep(i,0,n){
if(arr[i]==0 && order[i]==-1){
order[i]=cnt;
cnt++;
rep(j,1,k){
arr[(i-j+n)%n]--;
}
}
}
}
}
return;
}
int trial[1000000];
bool visited[1000000];
bool elim(int i, bool do_it){
if(visited[i])return false;
if(trial[i]>0)return false;
visited[i]=true;
bool rev=false;
rep(j,1,K){
if(!visited[(i-j+n)%n]){
trial[(i-j+n)%n]--;
if(trial[(i-j+n)%n]<0)rev=true;
}
}
if(rev){
rep(j,1,K){
if(!visited[(i-j+n)%n]){
trial[(i-j+n)%n]++;
}
}
visited[i]=false;
return false;
}else{
if(!do_it){
rep(j,1,K){
if(!visited[(i-j+n)%n]){
trial[(i-j+n)%n]++;
}
}
visited[i]=false;
}
return true;
}
}
int compare_plants(int x, int y) {
if(2*K>n){
if(order[x]>order[y])return -1;
return 1;
}
rep(i,0,n)trial[i]=arr[i];
rep(i,0,n)visited[i]=false;
rep(turn,0,n+1){
rep(i,0,n){
if(i!=x && i!=y){
elim(i,true);
}
}
}
/*rep(i,0,n)cout<<trial[i]<<" ";
cout<<endl;
rep(i,0,n)cout<<visited[i]<<" ";
cout<<endl;*/
//cout<<elim(x,false)<<" "<<elim(y,false)<<endl;
if(elim(x,false) && elim(y,false))return 0;
if(elim(x,false))return 1;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
232 ms |
4040 KB |
Output is correct |
7 |
Execution timed out |
4073 ms |
5156 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Execution timed out |
4093 ms |
4436 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
3 ms |
212 KB |
Output is correct |
6 |
Correct |
229 ms |
400 KB |
Output is correct |
7 |
Execution timed out |
4038 ms |
1108 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 KB |
Output is correct |
5 |
Execution timed out |
4037 ms |
316 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
232 ms |
4040 KB |
Output is correct |
7 |
Execution timed out |
4073 ms |
5156 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |