제출 #971441

#제출 시각아이디문제언어결과실행 시간메모리
971441Pannda밀림 점프 (APIO21_jumps)C++17
8 / 100
4010 ms1048576 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 12345; vector<vector<int>> dist; void init(int n, vector<int> h) { dist = vector<vector<int>>(n, vector<int>(n, INF)); for (int i = 0; i < n; i++) { dist[i][i] = 0; } for (int i = 0; i < n; i++) { for (int j = i - 1; j >= 0; j--) { if (h[j] > h[i]) { dist[i][j] = 1; break; } } for (int j = i + 1; j < n; j++) { if (h[j] > h[i]) { dist[i][j] = 1; break; } } } for (int m = 0; m < n; m++) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dist[i][j] = min(dist[i][j], dist[i][m] + dist[m][j]); } } } } int minimum_jumps(int l0, int r0, int l1, int r1) { r0++; r1++; int res = INF; for (int i = l0; i < r0; i++) { for (int j = l1; j < r1; j++) { res = min(res, dist[i][j]); } } if (res == INF) return -1; return res; }
#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...