Submission #983654

#TimeUsernameProblemLanguageResultExecution timeMemory
983654NexusRainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N=2e5+9,M=2e18+9,mod=1e9+7; bool vis[N]; pair<ll,ll>p; vector<ll>v[N]; ll a[N],n,x,y,z; queue<pair<ll,ll>>q; void init(int m,vector<int>h) { n=m; for(ll i=0;i<n;++i)a[i]=h[i]; for(ll i=0;i<n;++i) { for(ll j=i-1;j>=0;--j) { if(a[j]>a[i]) { v[i].push_back(j); break; } } for(ll j=i+1;j<n;++j) { if(a[j]>a[i]) { v[i].push_back(j); break; } } } } int minimum_jumps(int A, int B, int C, int D) { x=-1; for(ll i=A;i<=B;++i) { q.push({i,0}); memset(vis,false,sizeof vis); while(q.size()) { p=q.front(); q.pop(); if(vis[p.first])continue; vis[p.first]=1; if(C<=p.first && p.first<=D) x=(x==-1?p.second:min(x,p.second)); ++p.second; for(auto j:v[p.first])q.push({j,p.second}); } } } return x; }

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:59:5: warning: no return statement in function returning non-void [-Wreturn-type]
   59 |     }
      |     ^
jumps.cpp: At global scope:
jumps.cpp:60:5: error: expected unqualified-id before 'return'
   60 |     return x;
      |     ^~~~~~
jumps.cpp:61:1: error: expected declaration before '}' token
   61 | }
      | ^