This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,k,R[200009],cnt,f[200009];
void init(int Kk, vector<int> Rr) {
a=Rr.size();k=Kk-1;
for(i=0; i<a; i++){
R[i]=Rr[i];
}
cnt=a;
while(cnt>0){
for(i=0; i<a; i++){
if(f[i]!=0) continue;
if(R[i]==0){
e=0;
for(j=i-1; j>=i-k; j--){
if(f[(j+a)%a]!=0) continue;
if(R[(j+a)%a]==0){
e=1;
break;
}
}
if(e==0){
for(j=i-1; j>=i-k; j--){
if(f[(j+a)%a]!=0) continue;
R[(j+a)%a]--;
}
f[i]=cnt;cnt--;break;
}
}
}
}
return;
}
int compare_plants(int x, int y) {
if(f[x]>f[y]){
return 1;
}else{
return -1;
}
return 0;
}
/*int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int TES=0,TE=0;
cin>>a>>k>>TES;
vector <int> Rr;
Rr.resize(a);
for(i=0; i<a; i++){
cin>>R[i];
//Rr.push_back(c);
}
for(i=0; i<a; i++){
for(j=i+1; j<i+k; j++){
if(R[j%a]>R[i]) Rr[i]++;
}
}
init(k,Rr);
for(i=0; i<a; i++){
cout<<f[i]<<" ";
}
cout<<endl;
return 0;
for(TE=1; TE<=TES; TE++){
cin>>c>>d;
cout<<compare_plants(c,d)<<endl;
}
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |