답안 #365403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365403 2021-02-11T15:34:02 Z valerikk 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

namespace solver {
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 = 0; i < n; i++) {
            if (r[i] == 0)
                pos = i;
        }
        assert(~pos);
        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;
}
}

namespace tester {
void test() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> r(n);
    for (int i = 0; i < n; i++) 
        cin >> r[i];
    
    solver::init(k, r);
  
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << solver::compare_plants(x, y) << "\n";
    }
}
}

#ifndef EVAL
int main() {
    freopen("D:/cp/oi/ioi/2020/input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    tester::test();
    
    return 0;
}
#else
using namespace solver;
#endif

Compilation message

/tmp/ccNBofu5.o: In function `main':
grader.cpp:(.text.startup+0x316): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
grader.cpp:(.text.startup+0x357): undefined reference to `compare_plants(int, int)'
collect2: error: ld returned 1 exit status