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;
vector<int> R;
vector<int> pre;
int K, N;
void init(int k, vector<int> r)
{
N = r.size();
R = r; k = K;
pre.resize(N);
int s = 0;
for (; s < N; s++)
{
if (r[s] == 0)
break;
}
for (int i = s; i < N; i++)
{
if (r[i])
pre[i] = pre[i-1] + 1;
}
if (r[0])
{
pre[0] = pre[N-1] + 1;
for (int i = 1; i < s; i++)
pre[i] = pre[i-1] + 1;
}
for (int i = 0; i < N; i++)
{
pre.push_back(pre[i]);
}
}
int compare_plants(int x, int y)
{
if (y - pre[y] <= x)
return -1;
if (x + N - pre[x+N] <= y)
return 1;
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... |