제출 #565550

#제출 시각아이디문제언어결과실행 시간메모리
565550MurotY밀림 점프 (APIO21_jumps)C++14
0 / 100
4067 ms4308 KiB
#include "jumps.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int N=2*1e3+7; vector <int> a; vector <int> g[N]; bool u[N], u1[N]; int dp[N][N]; void dfs(int i, int v, int res=0){ u[v]=u1[v]=1; dp[i][v]=min(dp[i][v], res); for (auto l:g[v]){ if (!u[l]) dfs(i, l, res+1); } u[v]=0; } void init(int N, std::vector<int> H) { int n=N; a=H; vector <int> v; for (int i=n-1;i>=0;i--){ while (!v.empty() && a[i] > a[v.back()]) v.pop_back(); if (!v.empty()) g[i].push_back(v.back()); v.push_back(i); } v.clear(); for (int i=0;i<n;i++){ while (!v.empty() && a[i] > a[v.back()]) v.pop_back(); if (!v.empty()) g[i].push_back(v.back()); v.push_back(i); } for (int i=0;i<n;i++){ for (int j=0;j<n;j++) dp[i][j]=1e9; fill(u1, u1+n+10, 0); for (int j=0;j<n;j++){ if (!u1[i]){ dfs(i, i, 0); } } } /* for (int i=0;i<n;i++){ for (int j=0;j<n;j++) cout << dp[i][j] <<" "; cout <<"\n"; }*/ } int minimum_jumps(int A, int B, int C, int D) { int ans=1e9; for (int i=A;i<=B;i++){ for (int j=C;j<=D;j++){ ans=min(ans, dp[i][j]); } } if (ans == 1e9) ans=-1; return ans; }
#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...