이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> cntGreater; // how many following this are greater than this
vector<int> cntLess; // how many following this are less than this
int n;
void init(int k, std::vector<int> r) {
n = r.size();
cntGreater.resize(n);
int i = 0;
while (r[i] == 1) ++i;
cntGreater[i] = 0;
for (int j = (i-1+n)%n; j != i; j = (j-1+n)%n) {
if (r[j] == 1) cntGreater[j] = cntGreater[(j+1)%n] + 1;
else cntGreater[j] = 0;
}
cntLess.resize(n);
i = 0;
while (r[i] == 0) ++i;
cntLess[i] = 0;
for (int j = (i-1+n)%n; j != i; j = (j-1+n)%n) {
if (r[j] == 0) cntLess[j] = cntLess[(j+1)%n] + 1;
else cntLess[j] = 0;
}
return;
}
int compare_plants(int x, int y) {
if (cntGreater[x] >= y-x) return -1;
if (cntLess[x] >= y-x) return 1;
if (cntGreater[y] >= n+x-y) return 1;
if (cntLess[y] >= n+x-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... |