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;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
const int MAXN = 2e5+10;
int cam[MAXN], N;
void init(int k, vector<int> r) {
N=(int)r.size();
int cnt=0;
while(1){
vector<int> zero;
for(int i=0;i<N;i++)
if(!r[i]) zero.pb(i);
if(zero.empty()) break;
vector<int> proc;
if((int)zero.size()==1 || zero[0]-zero[(int)zero.size()-1]+N>=k) proc.pb(zero[0]);
for(int i=1;i<(int)zero.size();i++)
if(zero[i]-zero[i-1]>=k) proc.pb(zero[i]);
for(auto u : proc){
cam[u]=cnt;
for(int i=u;i>=u-k+1;i--)
r[(i+N)%N]--;
}
cnt++;
}
}
int compare_plants(int x, int y) {
if(cam[x]==cam[y]) return 0;
if(cam[x]<cam[y]) return 1;
return -1;
}
# | 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... |