Submission #478175

# Submission time Handle Problem Language Result Execution time Memory
478175 2021-10-06T07:47:01 Z khoabright Rainforest Jumps (APIO21_jumps) C++17
21 / 100
4000 ms 4892 KB
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define rep1(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define mp make_pair

const int N = 2e5 + 5;

int L[N], R[N], h[N];
int my_size;

void cal_LR() {
    rep(i, 1, my_size) {
        rep1(j, i - 1, 1) if (h[j] > h[i]) {
            L[i] = j;
            break;
        } 
        rep(j, i + 1, my_size) if (h[j] > h[i]) {
            R[i] = j;
            break;
        }
    }
}



int minimum_jumps(int a, int b, int c, int d) {
    ++a, ++b, ++c, ++d;
    queue<pii> q;
    vector<bool> vst(my_size + 1);
    vst[0] = 1;

    rep(i, a, b) q.push({i, 0}), vst[i] = 1;

    while (!q.empty()) {
        auto [u, w] = q.front();
        q.pop();
        if (c <= u && u <= d) return w;
        int v = L[u];
        if (!vst[v]) {
            q.push({v, w + 1});
            vst[v] = 1;
        }
        v = R[u];
        if (!vst[v]) {
            q.push({v, w + 1});
            vst[v] = 1;
        }
    }

    return -1;
}

void init(int sz, vector<int> array) {
    my_size = sz;
    rep(i, 1, my_size) h[i] = array[i - 1];   
    cal_LR();
}

// int main() {
//     ios_base::sync_with_stdio(0);
//     cin.tie(0); cout.tie(0);

//     // int x; cin >> x;
//     // int array[10];
//     // rep(i, 1, x) cin >> array[i - 1];
//     // init(x,array);
    
//     // rep(i, 1, my_size) cout << h[i] << ' ';
//     // cout << '\my_size';
//     // rep(i, 1, my_size) cout << L[i] << ' ' << R[i]<< '\my_size';

//     // int q; cin >> q;
//     // while (q--) {
//     //     int A, B, C, D;
//     //     cin >> A >> B >> C >> D;
//     //     cout << minimum_jumps(A + 1, B + 1, C + 1, D + 1) << '\my_size';
//     // }
// }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Execution timed out 4043 ms 2732 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 2 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 2 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 2 ms 200 KB Output is correct
16 Correct 2 ms 200 KB Output is correct
17 Correct 3 ms 200 KB Output is correct
18 Correct 0 ms 200 KB Output is correct
19 Correct 1 ms 200 KB Output is correct
20 Correct 5 ms 200 KB Output is correct
21 Correct 3 ms 200 KB Output is correct
22 Correct 3 ms 200 KB Output is correct
23 Correct 3 ms 200 KB Output is correct
24 Correct 2 ms 200 KB Output is correct
25 Correct 0 ms 200 KB Output is correct
26 Correct 0 ms 200 KB Output is correct
27 Correct 2 ms 200 KB Output is correct
28 Correct 3 ms 200 KB Output is correct
29 Correct 4 ms 200 KB Output is correct
30 Correct 3 ms 200 KB Output is correct
31 Correct 3 ms 200 KB Output is correct
32 Correct 3 ms 200 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 0 ms 200 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 200 KB Output is correct
37 Correct 0 ms 200 KB Output is correct
38 Correct 0 ms 200 KB Output is correct
39 Correct 1 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 2 ms 200 KB Output is correct
8 Correct 2 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 2 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 2 ms 200 KB Output is correct
16 Correct 2 ms 200 KB Output is correct
17 Correct 3 ms 200 KB Output is correct
18 Correct 0 ms 200 KB Output is correct
19 Correct 1 ms 200 KB Output is correct
20 Correct 5 ms 200 KB Output is correct
21 Correct 3 ms 200 KB Output is correct
22 Correct 3 ms 200 KB Output is correct
23 Correct 3 ms 200 KB Output is correct
24 Correct 2 ms 200 KB Output is correct
25 Correct 0 ms 200 KB Output is correct
26 Correct 0 ms 200 KB Output is correct
27 Correct 2 ms 200 KB Output is correct
28 Correct 3 ms 200 KB Output is correct
29 Correct 4 ms 200 KB Output is correct
30 Correct 3 ms 200 KB Output is correct
31 Correct 3 ms 200 KB Output is correct
32 Correct 3 ms 200 KB Output is correct
33 Correct 1 ms 200 KB Output is correct
34 Correct 0 ms 200 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 200 KB Output is correct
37 Correct 0 ms 200 KB Output is correct
38 Correct 0 ms 200 KB Output is correct
39 Correct 1 ms 200 KB Output is correct
40 Correct 1 ms 200 KB Output is correct
41 Correct 1 ms 200 KB Output is correct
42 Correct 0 ms 200 KB Output is correct
43 Correct 1 ms 200 KB Output is correct
44 Correct 3 ms 200 KB Output is correct
45 Correct 3 ms 200 KB Output is correct
46 Correct 1 ms 200 KB Output is correct
47 Correct 3 ms 200 KB Output is correct
48 Correct 1 ms 200 KB Output is correct
49 Correct 3 ms 200 KB Output is correct
50 Correct 4 ms 200 KB Output is correct
51 Correct 3 ms 200 KB Output is correct
52 Correct 3 ms 200 KB Output is correct
53 Correct 2 ms 200 KB Output is correct
54 Correct 5 ms 240 KB Output is correct
55 Correct 4 ms 200 KB Output is correct
56 Correct 4 ms 200 KB Output is correct
57 Correct 0 ms 200 KB Output is correct
58 Correct 28 ms 328 KB Output is correct
59 Correct 34 ms 328 KB Output is correct
60 Correct 8 ms 200 KB Output is correct
61 Correct 39 ms 348 KB Output is correct
62 Correct 12 ms 200 KB Output is correct
63 Correct 39 ms 328 KB Output is correct
64 Correct 44 ms 328 KB Output is correct
65 Correct 62 ms 328 KB Output is correct
66 Correct 53 ms 328 KB Output is correct
67 Correct 33 ms 328 KB Output is correct
68 Correct 57 ms 328 KB Output is correct
69 Correct 39 ms 352 KB Output is correct
70 Correct 21 ms 328 KB Output is correct
71 Correct 0 ms 200 KB Output is correct
72 Correct 0 ms 200 KB Output is correct
73 Correct 3 ms 200 KB Output is correct
74 Correct 4 ms 200 KB Output is correct
75 Correct 3 ms 200 KB Output is correct
76 Correct 3 ms 200 KB Output is correct
77 Correct 3 ms 200 KB Output is correct
78 Correct 0 ms 200 KB Output is correct
79 Correct 0 ms 200 KB Output is correct
80 Correct 2 ms 200 KB Output is correct
81 Correct 3 ms 200 KB Output is correct
82 Correct 3 ms 200 KB Output is correct
83 Correct 3 ms 200 KB Output is correct
84 Correct 2 ms 200 KB Output is correct
85 Correct 4 ms 200 KB Output is correct
86 Correct 0 ms 200 KB Output is correct
87 Correct 0 ms 200 KB Output is correct
88 Correct 0 ms 200 KB Output is correct
89 Correct 1 ms 200 KB Output is correct
90 Correct 0 ms 200 KB Output is correct
91 Correct 1 ms 200 KB Output is correct
92 Correct 0 ms 200 KB Output is correct
93 Correct 0 ms 200 KB Output is correct
94 Correct 3 ms 208 KB Output is correct
95 Correct 40 ms 336 KB Output is correct
96 Correct 50 ms 336 KB Output is correct
97 Correct 42 ms 336 KB Output is correct
98 Correct 58 ms 336 KB Output is correct
99 Correct 50 ms 336 KB Output is correct
100 Correct 0 ms 200 KB Output is correct
101 Correct 1 ms 200 KB Output is correct
102 Correct 25 ms 328 KB Output is correct
103 Correct 44 ms 328 KB Output is correct
104 Correct 18 ms 328 KB Output is correct
105 Correct 32 ms 328 KB Output is correct
106 Correct 42 ms 328 KB Output is correct
107 Correct 0 ms 200 KB Output is correct
108 Correct 0 ms 200 KB Output is correct
109 Correct 1 ms 328 KB Output is correct
110 Correct 2 ms 344 KB Output is correct
111 Correct 1 ms 328 KB Output is correct
112 Correct 2 ms 328 KB Output is correct
113 Correct 2 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 23 ms 3492 KB Output is correct
6 Correct 32 ms 4160 KB Output is correct
7 Correct 13 ms 2204 KB Output is correct
8 Correct 32 ms 4892 KB Output is correct
9 Correct 7 ms 840 KB Output is correct
10 Correct 30 ms 4124 KB Output is correct
11 Execution timed out 4054 ms 3156 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 315 ms 2072 KB Output is correct
5 Correct 1276 ms 4132 KB Output is correct
6 Correct 674 ms 968 KB Output is correct
7 Correct 1233 ms 4140 KB Output is correct
8 Correct 705 ms 1564 KB Output is correct
9 Correct 1184 ms 4160 KB Output is correct
10 Execution timed out 4030 ms 3212 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 315 ms 2072 KB Output is correct
5 Correct 1276 ms 4132 KB Output is correct
6 Correct 674 ms 968 KB Output is correct
7 Correct 1233 ms 4140 KB Output is correct
8 Correct 705 ms 1564 KB Output is correct
9 Correct 1184 ms 4160 KB Output is correct
10 Execution timed out 4030 ms 3212 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Execution timed out 4043 ms 2732 KB Time limit exceeded
4 Halted 0 ms 0 KB -