이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int c;
const int N = 500000;
int H[N];
void call(int i, int k, int n, vector<int> &r, vector<int> &h1)
{
for (int j = i - 1; j > i - k; j--)
{
int id = (j + n) % n;
if (r[id] == 0 && h1[id] == 0)
{
call(id, k, n, r, h1);
}
}
h1[i] = c--;
for (int j = i - 1; j > i - k; j--)
{
int id = (j + n) % n;
r[id]--;
}
}
void init(int k, vector<int> r)
{
int n = r.size();
vector<int> h1(n);
c = n;
int t = 1;
while (t)
{
t = 0;
for (int i = 0; i < n; i++)
{
if (r[i] == 0 && h1[i] == 0)
{
call(i, k, n, r, h1);
t = 1;
}
}
}
for (int i = 0; i < n; i++)
{
H[i] = h1[i];
}
}
int compare_plants(int x, int y)
{
if (H[x] > H[y]) return 1;
return -1;
}
#ifdef LOCAL
int main()
{
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);
while (q--)
{
int x, y;
cin >> x >> y;
cout << compare_plants(x, y) << endl;
}
}
#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... |