이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "plants.h"
#include <queue>
#define pb push_back
using namespace std;
vector<int> h;
void init(int k, vector<int> r) {
    int n = r.size();
    int x = n;
    h.resize(n);
    for (int i = 0; i < n; ++i) {
        r.pb(r[i]);
    }
    for (int i = 0; i < n; ++i) {
        queue<int> q;
        for (int j = 0; j < n; ++j) {
            if (!q.empty() && q.front() < j - k + 1) q.pop();
            if (r[j] == 0) q.push(j);
        }
        int cur = 0;
        for (int j = n; j < 2*n; ++j) {
            if (!q.empty() && q.front() < j - k + 1) q.pop();
            if (r[j] == 0 && q.empty()){
                cur = j;
                break;
            }
            if (r[j] == 0) q.push(j);
        }
        h[cur%n] = x--;
        for (int j = cur; j > cur - k ; --j) {
            r[j]--;
            if (j >= n) r[j-n]--;
            else r[j+n]--;
        }
    }
}
int compare_plants(int x, int y) {
    if (h[x] > h[y]) return 1;
    else return -1;
}
| # | 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... |