이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int k, n;
vector<int> r;
vector<int> h;
void build_h() {
h = vector<int>(n, -1);
for (int t = n - 1; t >= 0; t--) {
int pos = -1;
for (int i = n - 1; i >= 0; i--) {
if (r[i] == 0 && h[i] == -1 && (pos == -1 || (pos - i + n) % n < k))
pos = i;
}
for (int i = n - 1; i >= 0; i--) {
if (r[i] == 0 && h[i] == -1 && (pos == -1 || (pos - i + n) % n < k))
pos = i;
}
assert(pos != -1);
h[pos] = t;
for (int i = 1; i < k; i++)
r[(pos - i + n) % n]--;
}
}
void init(int k_, vector<int> r_) {
n = r_.size();
k = k_;
r = r_;
build_h();
}
int compare_plants(int x, int y) {
return h[x] > h[y] ? 1 : -1;
}
#ifndef EVAL
void test() {
int n, k, q;
cin >> n >> k >> q;
vector<int> r(n);
for (int i = 0; i < n; i++)
cin >> r[i];
init(k, r);
for (int i = 0; i < q; i++) {
int x, y;
cin >> x >> y;
cout << compare_plants(x, y) << "\n";
}
}
int main() {
freopen("D:/cp/oi/ioi/2020/input.txt", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0);
test();
return 0;
}
#endif
# | 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... |