#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
int adj[201][201];
int inf = INT_MAX;
void init(int n, std::vector<int> H) {
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
adj[i][j] = inf;
for(int i=0;i<n;i++)
adj[i][i] = 0;
for(int i=0;i<n-1;i++)
for(int j=i+1;j<n;j++)
if(H[i] < H[j])
adj[i][j] = 1;
for(int i=1;i<n;i++)
for(int j=i-1;j>=0;j--)
if(H[i] < H[j])
adj[i][j] = 1;
int i, j, k;
for(k=0;k<n;k++)
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if (adj[i][j] > (adj[i][k] + adj[k][j])
&& (adj[k][j] != inf
&& adj[i][k] != inf))
adj[i][j] = adj[i][k] + adj[k][j];
}
}
}
}
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(adj[i][j], ans);
}
if(ans == inf)
return -1;
else
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
25 ms |
3216 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Runtime error |
18 ms |
2076 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Runtime error |
18 ms |
2076 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Runtime error |
25 ms |
3216 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |