Submission #1211196

#TimeUsernameProblemLanguageResultExecution timeMemory
1211196fafnirComparing Plants (IOI20_plants)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define LOCAL using namespace std; const int NMAX = 200'001; int n,k,q; int r[NMAX]; int rpref[NMAX+1]; void init(int kl, vector<int> rl) { n = rl.size(); k = kl; for (int i = 0; i < n; ++i) { r[i] = rl[i]; } rpref[0] = 0; for (int i = 1; i <= n; ++i) { rpref[i] += rpref[i-1]; rpref[i] += r[i-1]; } } bool isGreater(int x, int y) { if (x < y) { int s0 = rpref[y+1] - rpref[x]; int s1 = (rpref[n] - rpref[y]) + (rpref[x]-rpref[0]); if (s0 == 0 || s1 == (n-1-y+1 + x-1-0+1)) return true; else return false; } else { int s0 = rpref[y+1] - rpref[x]; int s1 = (rpref[n] - rpref[y]) + (rpref[x]-rpref[0]); if (s1 == 0 || s0 == (y-1-x+1)) return true; else return false; } } // 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) { assert(x < y); if (isGreater(x, y)) { return 1; } else if (isGreater(y, x)) { return -1; } else { 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/ccD1268W.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccMj1sJo.o:plants.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status