#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
int adj[201][201];
int inf = INT_MAX;
int sb1 = 1;
void init(int n, vector<int> H) {
for(int i=0;i<n-1;i++)
if(H[i + 1] != H[i] + 1)
{
sb1 = 0;
break;
}
if(sb1)
return;
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;i++)
for(int j=i+1;j<n;j++)
if(H[i] < H[j])
{
adj[i][j] = 1;
break;
}
for(int i=0;i<n;i++)
for(int j=i-1;j>=0;j--)
if(H[i] < H[j])
{
adj[i][j] = 1;
break;
}
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) {
if(sb1)
return C - B;
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 |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
59 ms |
1428 KB |
Output is correct |
4 |
Correct |
656 ms |
1848 KB |
Output is correct |
5 |
Correct |
642 ms |
1088 KB |
Output is correct |
6 |
Correct |
756 ms |
1848 KB |
Output is correct |
7 |
Correct |
645 ms |
1320 KB |
Output is correct |
8 |
Correct |
747 ms |
1816 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
12 ms |
336 KB |
Output is correct |
7 |
Correct |
7 ms |
336 KB |
Output is correct |
8 |
Correct |
10 ms |
452 KB |
Output is correct |
9 |
Correct |
6 ms |
336 KB |
Output is correct |
10 |
Correct |
10 ms |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
16 ms |
336 KB |
Output is correct |
13 |
Correct |
12 ms |
448 KB |
Output is correct |
14 |
Correct |
12 ms |
448 KB |
Output is correct |
15 |
Correct |
13 ms |
448 KB |
Output is correct |
16 |
Correct |
14 ms |
336 KB |
Output is correct |
17 |
Correct |
9 ms |
452 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
11 ms |
452 KB |
Output is correct |
21 |
Correct |
12 ms |
336 KB |
Output is correct |
22 |
Correct |
9 ms |
336 KB |
Output is correct |
23 |
Correct |
11 ms |
452 KB |
Output is correct |
24 |
Correct |
9 ms |
336 KB |
Output is correct |
25 |
Correct |
0 ms |
208 KB |
Output is correct |
26 |
Correct |
0 ms |
208 KB |
Output is correct |
27 |
Correct |
2 ms |
208 KB |
Output is correct |
28 |
Correct |
10 ms |
336 KB |
Output is correct |
29 |
Correct |
12 ms |
448 KB |
Output is correct |
30 |
Correct |
8 ms |
336 KB |
Output is correct |
31 |
Correct |
11 ms |
452 KB |
Output is correct |
32 |
Correct |
9 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
6 ms |
336 KB |
Output is correct |
35 |
Correct |
8 ms |
336 KB |
Output is correct |
36 |
Correct |
11 ms |
336 KB |
Output is correct |
37 |
Correct |
10 ms |
336 KB |
Output is correct |
38 |
Correct |
11 ms |
336 KB |
Output is correct |
39 |
Correct |
13 ms |
336 KB |
Output is correct |
# |
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 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
12 ms |
336 KB |
Output is correct |
7 |
Correct |
7 ms |
336 KB |
Output is correct |
8 |
Correct |
10 ms |
452 KB |
Output is correct |
9 |
Correct |
6 ms |
336 KB |
Output is correct |
10 |
Correct |
10 ms |
336 KB |
Output is correct |
11 |
Correct |
3 ms |
208 KB |
Output is correct |
12 |
Correct |
16 ms |
336 KB |
Output is correct |
13 |
Correct |
12 ms |
448 KB |
Output is correct |
14 |
Correct |
12 ms |
448 KB |
Output is correct |
15 |
Correct |
13 ms |
448 KB |
Output is correct |
16 |
Correct |
14 ms |
336 KB |
Output is correct |
17 |
Correct |
9 ms |
452 KB |
Output is correct |
18 |
Correct |
1 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
208 KB |
Output is correct |
20 |
Correct |
11 ms |
452 KB |
Output is correct |
21 |
Correct |
12 ms |
336 KB |
Output is correct |
22 |
Correct |
9 ms |
336 KB |
Output is correct |
23 |
Correct |
11 ms |
452 KB |
Output is correct |
24 |
Correct |
9 ms |
336 KB |
Output is correct |
25 |
Correct |
0 ms |
208 KB |
Output is correct |
26 |
Correct |
0 ms |
208 KB |
Output is correct |
27 |
Correct |
2 ms |
208 KB |
Output is correct |
28 |
Correct |
10 ms |
336 KB |
Output is correct |
29 |
Correct |
12 ms |
448 KB |
Output is correct |
30 |
Correct |
8 ms |
336 KB |
Output is correct |
31 |
Correct |
11 ms |
452 KB |
Output is correct |
32 |
Correct |
9 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
6 ms |
336 KB |
Output is correct |
35 |
Correct |
8 ms |
336 KB |
Output is correct |
36 |
Correct |
11 ms |
336 KB |
Output is correct |
37 |
Correct |
10 ms |
336 KB |
Output is correct |
38 |
Correct |
11 ms |
336 KB |
Output is correct |
39 |
Correct |
13 ms |
336 KB |
Output is correct |
40 |
Correct |
1 ms |
208 KB |
Output is correct |
41 |
Correct |
0 ms |
208 KB |
Output is correct |
42 |
Correct |
1 ms |
208 KB |
Output is correct |
43 |
Correct |
0 ms |
208 KB |
Output is correct |
44 |
Correct |
2 ms |
208 KB |
Output is correct |
45 |
Correct |
10 ms |
336 KB |
Output is correct |
46 |
Correct |
9 ms |
464 KB |
Output is correct |
47 |
Correct |
13 ms |
452 KB |
Output is correct |
48 |
Correct |
5 ms |
336 KB |
Output is correct |
49 |
Correct |
13 ms |
336 KB |
Output is correct |
50 |
Correct |
2 ms |
208 KB |
Output is correct |
51 |
Correct |
12 ms |
452 KB |
Output is correct |
52 |
Correct |
10 ms |
452 KB |
Output is correct |
53 |
Correct |
10 ms |
336 KB |
Output is correct |
54 |
Correct |
11 ms |
336 KB |
Output is correct |
55 |
Correct |
13 ms |
336 KB |
Output is correct |
56 |
Correct |
10 ms |
336 KB |
Output is correct |
57 |
Correct |
8 ms |
424 KB |
Output is correct |
58 |
Runtime error |
1 ms |
720 KB |
Execution killed with signal 11 |
59 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Runtime error |
20 ms |
3188 KB |
Execution killed with signal 11 |
6 |
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 |
19 ms |
2120 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 |
19 ms |
2120 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
59 ms |
1428 KB |
Output is correct |
4 |
Correct |
656 ms |
1848 KB |
Output is correct |
5 |
Correct |
642 ms |
1088 KB |
Output is correct |
6 |
Correct |
756 ms |
1848 KB |
Output is correct |
7 |
Correct |
645 ms |
1320 KB |
Output is correct |
8 |
Correct |
747 ms |
1816 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
0 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
3 ms |
208 KB |
Output is correct |
14 |
Correct |
12 ms |
336 KB |
Output is correct |
15 |
Correct |
7 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
452 KB |
Output is correct |
17 |
Correct |
6 ms |
336 KB |
Output is correct |
18 |
Correct |
10 ms |
336 KB |
Output is correct |
19 |
Correct |
3 ms |
208 KB |
Output is correct |
20 |
Correct |
16 ms |
336 KB |
Output is correct |
21 |
Correct |
12 ms |
448 KB |
Output is correct |
22 |
Correct |
12 ms |
448 KB |
Output is correct |
23 |
Correct |
13 ms |
448 KB |
Output is correct |
24 |
Correct |
14 ms |
336 KB |
Output is correct |
25 |
Correct |
9 ms |
452 KB |
Output is correct |
26 |
Correct |
1 ms |
208 KB |
Output is correct |
27 |
Correct |
1 ms |
208 KB |
Output is correct |
28 |
Correct |
11 ms |
452 KB |
Output is correct |
29 |
Correct |
12 ms |
336 KB |
Output is correct |
30 |
Correct |
9 ms |
336 KB |
Output is correct |
31 |
Correct |
11 ms |
452 KB |
Output is correct |
32 |
Correct |
9 ms |
336 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
0 ms |
208 KB |
Output is correct |
35 |
Correct |
2 ms |
208 KB |
Output is correct |
36 |
Correct |
10 ms |
336 KB |
Output is correct |
37 |
Correct |
12 ms |
448 KB |
Output is correct |
38 |
Correct |
8 ms |
336 KB |
Output is correct |
39 |
Correct |
11 ms |
452 KB |
Output is correct |
40 |
Correct |
9 ms |
336 KB |
Output is correct |
41 |
Correct |
0 ms |
208 KB |
Output is correct |
42 |
Correct |
6 ms |
336 KB |
Output is correct |
43 |
Correct |
8 ms |
336 KB |
Output is correct |
44 |
Correct |
11 ms |
336 KB |
Output is correct |
45 |
Correct |
10 ms |
336 KB |
Output is correct |
46 |
Correct |
11 ms |
336 KB |
Output is correct |
47 |
Correct |
13 ms |
336 KB |
Output is correct |
48 |
Correct |
1 ms |
208 KB |
Output is correct |
49 |
Correct |
0 ms |
208 KB |
Output is correct |
50 |
Correct |
1 ms |
208 KB |
Output is correct |
51 |
Correct |
0 ms |
208 KB |
Output is correct |
52 |
Correct |
2 ms |
208 KB |
Output is correct |
53 |
Correct |
10 ms |
336 KB |
Output is correct |
54 |
Correct |
9 ms |
464 KB |
Output is correct |
55 |
Correct |
13 ms |
452 KB |
Output is correct |
56 |
Correct |
5 ms |
336 KB |
Output is correct |
57 |
Correct |
13 ms |
336 KB |
Output is correct |
58 |
Correct |
2 ms |
208 KB |
Output is correct |
59 |
Correct |
12 ms |
452 KB |
Output is correct |
60 |
Correct |
10 ms |
452 KB |
Output is correct |
61 |
Correct |
10 ms |
336 KB |
Output is correct |
62 |
Correct |
11 ms |
336 KB |
Output is correct |
63 |
Correct |
13 ms |
336 KB |
Output is correct |
64 |
Correct |
10 ms |
336 KB |
Output is correct |
65 |
Correct |
8 ms |
424 KB |
Output is correct |
66 |
Runtime error |
1 ms |
720 KB |
Execution killed with signal 11 |
67 |
Halted |
0 ms |
0 KB |
- |