Submission #497533

# Submission time Handle Problem Language Result Execution time Memory
497533 2021-12-23T08:18:58 Z Karliver Rainforest Jumps (APIO21_jumps) C++17
0 / 100
8 ms 9976 KB
    
#include <bits/stdc++.h>
#include "jumps.h"
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
#define sz(x) (int)x.size()
#define ff first
#define se second
#define mp make_pair
using ll = long long;
int mod = (ll)1e9 + 7;
const int INF = 1e9 + 1;

const double eps = 1e-7;

template <class T> using V = vector<T>;  
template <class T> using VV = V<V<T>>;  
template<class T, size_t SZ> using AR = array<T, SZ>;
template<class T> using PR = pair<T, T>;
template <typename XPAX>
bool ckma(XPAX &x, XPAX y) {
    return (x < y ? x = y, 1 : 0);
}
template <typename XPAX>
bool ckmi(XPAX &x, XPAX y) {
    return (x > y ? x = y, 1 : 0);
}

V<int> g[200001];

int dis[200001];
void init(int N, V<int> H) {
    stack<int> st;
    forn(i, N) {
        while(sz(st) && H[st.top()] < H[i])
            st.pop();
        g[i].push_back(st.top());
        st.push(i);
    }
    while(sz(st))st.pop();
    rforn(i, N) {
        while(sz(st) && H[st.top()] < H[i])
            st.pop();
        g[i].push_back(st.top());
        st.push(i);
    }
    forn(i, N) {
        dis[i] = -1;
    }

}

int minimum_jumps(int A, int B, int C, int D) {
    queue<int> q;
    V<int> clr;
    for(int a = A;a <= B;++a) {
        q.push(a);
        dis[a] = 0;
    }
    while(sz(q)) {
        int v = q.front();
        q.pop();
        if(C <= v && v <= D)
            return dis[v];
        for(auto c : g[v]) {
            if(dis[c] == -1) {
                dis[c] = dis[v]+1;
                q.push(c);
            }
        }
    }

    return -1;
}
        
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 9920 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9976 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9976 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 9848 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -