| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1211163 | fafnir | Comparing Plants (IOI20_plants) | C++20 | 0 ms | 0 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;
}
