이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Ignut
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, k;
vector<int> r;
vector<int> cntInRow;
void init(int K, vector<int> R) {
n = R.size();
k = K;
r = R;
for (int val : R) r.push_back(val);
cntInRow.resize(2 * n);
cntInRow[2 * n - 1] = 1;
for (int i = 2 * n - 2; i >= 0; i --)
cntInRow[i] = (r[i] == r[i + 1] ? cntInRow[i + 1] + 1 : 1);
}
int compare_plants(int x, int y) {
if (k == 2) {
if (x + cntInRow[x] >= y)
return r[x] == 1 ? -1 : 1;
if (y + cntInRow[y] - n >= x)
return r[y] == 1 ? 1 : -1;
return 0;
}
if (x + k - 1 >= y) {
if (x == 0) return 1;
if (x == k - 1) return -1;
}
if (y + k - 1 - n >= x) {
if (y == 0) return -1;
if (y == k - 1) 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... |