Submission #1177437

#TimeUsernameProblemLanguageResultExecution timeMemory
1177437stdfloatRainforest Jumps (APIO21_jumps)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "jumps.h" #include "stub.cpp" using namespace std; vector<int> H, L, R; void init(int n, vector<int> h) { H = h; stack<int> s; L = R = vector<int>(n); for (int i = 0; i < n; i++) { while (!s.empty() && h[s.top()] < h[i]) s.pop(); L[i] = (s.empty() ? -1 : s.top()); s.push(i); } while (!s.empty()) s.pop(); for (int i = n - 1; i >= 0; i--) { while (!s.empty() && h[i] > h[s.top()]) s.pop(); R[i] = (s.empty() ? -1 : s.top()); s.push(i); } } int minimum_jumps(int A, int B, int C, int D) { assert(A == B && C == D); int cnt = 0, x = A; while (x != C) { bool tr = false; if (~L[x] && (!~R[x] || H[L[x]] > H[R[x]]) && H[L[x]] <= H[C]) { x = L[x]; tr = true; } else if (~R[x] && (!~L[x] || H[L[x]] < H[R[x]]) && H[R[x]] <= H[C]) { x = R[x]; tr = true; } if (!tr) break; cnt++; } return (x == C ? cnt : -1); }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccBFaJpS.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccnykR95.o:jumps.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status