Submission #1196968

#TimeUsernameProblemLanguageResultExecution timeMemory
1196968GoBananas69도로 폐쇄 (APIO21_roads)C++20
Compilation error
0 ms0 KiB
#include <cassert>
#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>

#include "jumps.h"
using namespace std;
vector<vector<int>> adj;

bool subtask1 = true;
const int maxk = 17;
const int maxn = 1e5;

int L[maxn][maxk];
int R[maxn][maxk];

void init(int n, vector<int> h) {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < maxk; j++) {
            L[i][j] = n;
            R[i][j] = -1;
        }
    }

    vector<int> q;
    for (int i = 0; i < n; ++i) {
        if (h[i] != i + 1) subtask1 = false;
        while (!q.empty() && h[q.back()] < h[i]) {
            q.pop_back();
        }
        if (!q.empty()) {
            L[i][0] = q.back();
        }
        q.push_back(i);
    }
    q.clear();
    for (int i = n - 1; i >= 0; --i) {
        while (!q.empty() && h[q.back()] < h[i]) {
            q.pop_back();
        }
        if (!q.empty()) {
            R[i][0] = q.back();
        } 
        q.push_back(i);
    }

    for (int j = 1; j < maxk; j++) {
        for (int i = 0; i < n; i++) {
            int u = L[i][j - 1];
            int v = R[i][j - 1];
            R[i][j] = max(R[u][j - 1], R[v][j - 1]);
            L[i][j] = min(L[u][j - 1], L[v][j - 1]);
        }
    }
    
}

int minimum_jumps(int A, int B, int C, int D) {
    if (subtask1) {
        return C - B;
    }
    int n = adj.size();
    if (A == B && C == D) {
        int res = 0;
        int r = A;
        for (int j = maxk - 1; j >= 0; j--) {
            if (R[r][j] != -1 && R[r][j] < C) {
                r = R[r][j];
                res += (1 << j);
            }
        }
        if (R[r][0] == C) return res + 1;
        else return -1;
    }
    
    return -1;
}

Compilation message (stderr)

roads.cpp:7:10: fatal error: jumps.h: No such file or directory
    7 | #include "jumps.h"
      |          ^~~~~~~~~
compilation terminated.