이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "jumps.h"
using namespace std;
#include <vector>
#include <queue>
#include <iostream>
#define NMAX 2010
// #define NMAX 7
#define INF 1e5
vector<vector<int>> costs(NMAX,vector<int>(NMAX,INF));
vector<vector<int>> paths(NMAX,vector<int>(NMAX,0));
void init(int N, std::vector<int> H) {
for(int i = 0;i<N;i++)costs[i][i] = 0;
for(int i = 0;i<N;i++){
int pos = i+1;
while(pos<N){
if(H[i]<H[pos]){
paths[i][pos] = 1;
costs[i][pos] = 1;
break;
}pos++;
}
pos = i-1;
while(pos>-1){
if(H[i]<H[pos]){
paths[i][pos] = 1;
costs[i][pos] = 1;
break;
}pos--;
}
}
// for(int i=0;i<costs.size();i++){
// for(int j=0;j<costs[i].size();j++){
// cout << costs[i][j] << " ";
// }cout << endl;
// }
// for(int i=0;i<N;i++){
// cout << i << " -> ";
// for(int j=0;j<paths[i].size();j++){
// cout << paths[i][j] << ",";
// }cout << endl;
// }
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
for(int k=0;k<N;k++){
costs[i][j] = min(costs[i][j],costs[i][k]+costs[k][j]);
}
}
}
// for(int i=0;i<costs.size();i++){
// for(int j=0;j<costs[i].size();j++){
// cout << costs[i][j] << " ";
// }cout << endl;
// }
}
int minimum_jumps(int A, int B, int C, int D) {
int ans = INF;
for(int i=A;i<=B;i++){
for(int j=C;j<=D;j++){
ans = min(ans,costs[i][j]);
}
}
if(ans == INF)return -1;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |