Submission #1211168

#TimeUsernameProblemLanguageResultExecution timeMemory
1211168fafnirComparing Plants (IOI20_plants)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> // #define LOCAL using namespace std; const int KMAX = 100; const int NMAX = 100; const int QMAX = 100; int n,k,q; int r[NMAX]; void init(int kl, vector<int>& rl) { n = rl.size(); k = kl; for (int i = 0; i < n; ++i) { r[i] = rl[i]; } } // 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; } #ifdef LOCAL int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); int nl, kl, ql; cin >> nl >> kl >> ql; vector<int> rl(nl); for (auto& e : rl) cin >> e; init(kl, rl); for (int _ = 0; _ < ql; _++) { int x, y; cin >> x >> y; cout << compare_plants(x, y); if (_ < ql-1) cout << '\n'; } return 0; } #endif

Compilation message (stderr)

/usr/bin/ld: /tmp/cczv24nk.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