Submission #565097

#TimeUsernameProblemLanguageResultExecution timeMemory
565097Garguy22Rainforest Jumps (APIO21_jumps)C++17
0 / 100
1 ms336 KiB
#include <iostream> #include <vector> #include <queue> #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ff first #define ss second typedef pair<int, int> pii; vector<int> adj[2007]; bool vis[2007]; void init(int N, vector<int> H){ for(int i = 0; i < N; i++){ for(int j = i-1; j >= 0; j--){ if(H[j] > H[i]){ adj[i].pb(j); break; } } for(int j = i+1; j < N; j++){ if(H[j] > H[i]){ adj[i].pb(j); break; } } } } int minimum_jumps(int A, int B, int C, int D){ queue<pii> q; for(int i = A; i <= B; i++){ q.push(mp(0, i)); vis[i] = 1; } while(!q.empty()){ pii u = q.front(); q.pop(); if(u.ss >= C && u.ss <= D) return u.ff; for(int v : adj[u.ss]){ if(!vis[v]){ q.push(mp(u.ff + 1, u.ss)); vis[v] = 1; } } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...