Submission #740482

#TimeUsernameProblemLanguageResultExecution timeMemory
740482BerryisbetterRainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; using ll=long long; vector<ll> seg,br,d;ll n; vector<pair<ll,ll>>j; ll qw(ll a,ll b){ ll ans=0; for (a+=n,b+=n;a<b;a/=2,b/=2){ if (a%2){ ans=max(ans,seg[a]); a++; } if (b%2){ b--; ans=max(ans,seg[b]); } } return ans; } ll ind(ll v,ll a,ll b){ if (a==b){ return a; } ll m=(a+b)/2; if (qw(a,m)>=v){ return ind(v,a,m); } return ind(v,m+1,b); } /*#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n; cin >> n; vector<ll> a(n), r(n); for (ll i = 0; i < n; i++) { cin >> a[i]; r[i] = i - 1; } for (ll i = 0; i < n; i++) { ll j = i; while (r[j] != -1) { if (a[i] > a[r[j]]) { break; } j = r[j]; } r[i] = r[j]; cout << r[i] + 1 << '\n'; } }*/ void init(int N, std::vector<int> H) { n=N; seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n; //segment setup for (ll i=0;i<n;i++){ seg[i+n]=H[i]; } for (ll i=n;i>0;i--){ seg[i]=max(seg[2*i],seg[2*i+1]); } //br setup br=vector<ll>(n,0);for (ll i=0;i<n;i++){br[i]=i+1;} for (ll i = n-1; i >= 0; i--) { ll j = i; while (br[j] != n) { if (a[i] < a[r[j]]) { break; } j = br[j]; } br[i] = br[j]; } //distance d=vector<ll>(n+1);d[n]=0; for (ll i=0;i<n;i++){ d[i]=d[br[i]]+1; } } //ind,qw,d int minimum_jumps(int A, int B, int C, int D) { ll x=ind(seg[B+n],seg[C+n],seg[D+n]); if (d[B]>d[x]){ return d[B]-d[x]; } return -1; }

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:57:45: error: expected primary-expression before 'n'
   57 |  seg=vector<ll>(2*n,0);j=vector<pair<ll,ll>>n;
      |                                             ^
jumps.cpp:70:8: error: 'a' was not declared in this scope
   70 |    if (a[i] < a[r[j]]) {
      |        ^
jumps.cpp:70:17: error: 'r' was not declared in this scope
   70 |    if (a[i] < a[r[j]]) {
      |                 ^