답안 #969763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969763 2024-04-25T14:40:06 Z Pring Jakarta Skyscrapers (APIO15_skyscraper) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

const int MXN = 30005, INF = 1e9;
int n, m;
vector<int> pos, p;

namespace GRAPH {
    vector<int> bck[MXN];
    unordered_map<int, int> dis;
    unordered_map<int, bool> b;
    deque<int> dq;

    void ZOBFS(int sr, int to) {
        auto PUSH = [&](int id) -> void {
            auto PUT = [&](int i, int id, int w) -> void {
                if (b[i]) return;
                if (dis.find(i) == dis.end() || dis[i] < dis[id] + w) {
                    dis[i] = dis[id] + w;
                    if (w) dq.push_back(i);
                    else dq.push_front(i);
                }
            };
            if (id < n) {
                for (auto &i : bck[id]) PUT(i + n, id, 0);
                return;
            }
            if (id < n + m) {
                PUT(pos[id - n], id, 0);
                PUT(pos[id - n] * MXN + p[id - n] + n + m, id, 0);
                return;
            }
            id -= (n + m);
            int now = id / MXN, mod = id % MXN;
            PUT(now, id + n + m, 0);
            if (now - mod >= 0) PUT((now - mod) * MXN + mod + n + m, id + n + m, 1);
            if (now + mod < n) PUT((now + mod) * MXN + mod + n + m, id + n + m, 1);
        };
        dis[sr] = 0;
        dq.push_back(sr);
        int t = clock();
        while (dq.size() && clock() - t <= CLOCKS_PER_SEC / 10 * 7) {
            int id = dq.front();
            dq.pop_front();
            if (b[id]) continue;
            b[id] = true;
            PUSH(id);
            if (dis.find(to) != dis.end()) break;
        }
    }
}

int minimum_jumps(int N, int M, vector<int> &B, vector<int> &P) {
    using namespace GRAPH;
    // n = N;
    // m = M;
    // pos = B;
    // p = P;
    FOR(i, 0, m) bck[B[i]].push_back(i);
    ZOBFS(n, n + 1);
    if (dis.find(n + 1) == dis.end()) return -1;
    return dis[n + 1];
}

void miku() {
    int n, m;
    cin >> n >> m;
    // vector<int> b(m), p(m);
    pos.resize(m);
    p.resize(m);
    FOR(i, 0, m) cin >> pos[i] >> p[i];
    cout << minimum_jumps(n, m, b, p) << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

skyscraper.cpp: In function 'void miku()':
skyscraper.cpp:89:33: error: 'b' was not declared in this scope; did you mean 'GRAPH::b'?
   89 |     cout << minimum_jumps(n, m, b, p) << '\n';
      |                                 ^
      |                                 GRAPH::b
skyscraper.cpp:28:30: note: 'GRAPH::b' declared here
   28 |     unordered_map<int, bool> b;
      |                              ^