답안 #932598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
932598 2024-02-23T21:06:16 Z EJIC_B_KEDAX 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using ll = long long;

using namespace std;

const int N = 200200;
int level[N]

void init(int k, vector<int> r) {
    int n = r.size();
    int ok = 0, last = -k, lev = n;
    while (ok != n) {
        for (int i = n - 1; i >= n - k; i--) {
            if (!r[i]) {
                last = i - n;
                break;
            }
        }
        for (int i = 0; i < n; i++) {
            if (!r[i]) {
                if (i - last >= k) {
                    level[i] = lev;
                    ok++;
                    for (int j = i - 1; j > i - k; j++) {
                        if (j >= 0) {
                            r[j]--;
                        } else {
                            r[j + n]--;
                        }
                    }
                    r[i] = INT32_MAX;
                }
                last = i;
            }
        }
        lev--;
    }
}

int compare_plants(int x, int y) {
    if (level[x] < level[y]) {
        return -1;
    }
    return level[x] > level[y];
}

Compilation message

plants.cpp:10:1: error: expected initializer before 'void'
   10 | void init(int k, vector<int> r) {
      | ^~~~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:42:9: error: 'level' was not declared in this scope
   42 |     if (level[x] < level[y]) {
      |         ^~~~~
plants.cpp:45:12: error: 'level' was not declared in this scope
   45 |     return level[x] > level[y];
      |            ^~~~~