# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317529 | arnold518 | Comparing Plants (IOI20_plants) | C++14 | 277 ms | 8440 KiB |
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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 5000;
const int INF = 1e9;
int N, K, R[MAXN+10], H[MAXN+10];
void init(int _K, vector<int> _R)
{
K=_K; N=_R.size();
for(int i=0; i<N; i++) R[i]=_R[i];
for(int i=N-1; i>=0; i--)
{
vector<int> V;
for(int j=0; j<N; j++) if(R[j]==0) V.push_back(j);
//for(int j=0; j<N; j++) printf("%d ", R[j]); printf("\n");
for(int j=0; j<V.size(); j++)
{
int p=V[j], q;
if(j!=0) q=V[j-1];
else q=V[V.size()-1];
int d=(p-q+N)%N;
if(d==0) d+=N;
if(d>=K)
{
for(int k=(p-K+1+N)%N; k!=p; k=(k+1)%N) R[k]--;
R[p]=INF;
H[p]=i;
}
}
}
//for(int i=0; i<N; i++) printf("%d ", H[i]); printf("\n");
return;
}
int compare_plants(int x, int y)
{
int ans=0;
if(H[x]>H[y]) return 1;
if(H[x]<H[y]) return -1;
return 0;
}
Compilation message (stderr)
# | 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... |