제출 #1211163

#제출 시각아이디문제언어결과실행 시간메모리
1211163fafnirComparing Plants (IOI20_plants)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

const int KMAX = 100;
const int NMAX = 100;
const int QMAX = 100;

int n,k,q;
int r[NMAX];

// x, y: Labels of plants
//  Return:
//      1:   x taller than plant y
//     -1:   x smaller than plant y
//      0:   inconclusive
int compare_plants(int x, int y) {
    bool swapped = x > y;
    if (swapped) {swap(x,y);}


    bool rgeq = r[y];
    int idx0 = y;
    while (idx0 != x) {
        rgeq = rgeq && r[idx0];
        idx0 = (idx0+1) % n; 
    }

    bool lgeq = r[x];
    int idx1 = x;
    while (idx1 != y) {
        lgeq = lgeq && r[idx1];
        idx1 = (idx1+1) % n; 
    }

    // x > y
    if (rgeq) {
        return swapped ? -1 : 1;
    } else if (lgeq) {
        return swapped ? 1 : -1;
    }


    return 0;
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> k >> q;
    for (int i = 0; i < n; ++i) {
        cin >> r[i];
    }

    for (int _ = 0; _ < q; _++) {
        int x, y;
        cin >> x >> y;
        cout << compare_plants(x, y) << '\n';
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cc8jxSKx.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccBVQIlX.o:plants.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc8jxSKx.o: in function `main':
grader.cpp:(.text.startup+0x2e9): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status