Submission #488810

#TimeUsernameProblemLanguageResultExecution timeMemory
488810Theo830Rainforest Jumps (APIO21_jumps)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///APIO 2021 vc #include "jumps.h" vector<vector<ll> >adj; ll L[200005],R[200005]; vector<int>arr; void init(int N, std::vector<int> H){ arr = H; priority_queue<ii>pq; f(i,0,N){ L[i] = R[i] = INF; } f(i,0,N){ while(!pq.empty() && -pq.top().F < H[i]){ R[pq.top().S] = i; pq.pop(); } pq.push(ii(-H[i],i)); } while(!pq.empty()){ pq.pop(); } for(ll i = N-1;i >= 0;i--){ while(!pq.empty() && -pq.top().F < H[i]){ L[pq.top().S] = i; pq.pop(); } pq.push(ii(-H[i],i)); } f(i,0,N){ if(L[i] != INF){ adj[i].pb(L[i]); } if(R[i] != INF){ adj[i].pb(R[i]); } } } int minimum_jumps(int A, int B, int C, int D) { ll ans = 0; ll dist[n]; f(i,0,n){ dist[i] = INF; } queue<ll>q; f(s,A,B+1){ q.push(s); dist[s] = 0; } while(!q.empty()){ ll x = q.front(); q.pop(); for(auto y:adj[x]){ if(dist[y] == INF){ dist[y] = 1 + dist[x]; q.push(y); } } } return ans; }

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:63:13: error: 'n' was not declared in this scope
   63 |     ll dist[n];
      |             ^
jumps.cpp:65:9: error: 'dist' was not declared in this scope
   65 |         dist[i] = INF;
      |         ^~~~
jumps.cpp:70:9: error: 'dist' was not declared in this scope
   70 |         dist[s] = 0;
      |         ^~~~
jumps.cpp:76:16: error: 'dist' was not declared in this scope
   76 |             if(dist[y] == INF){
      |                ^~~~