제출 #1162199

#제출 시각아이디문제언어결과실행 시간메모리
1162199minhpkJakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;

const int MAX_POS = 300005;
const int MAX_TYPE = 181;
const long long INF = 1e18;

int a, b;
vector<int> z[MAX_POS];
int blocksize;
pair<int, int> mark[30005];

struct node {
    int val, pos, type;
    bool operator>(const node &other) const {
        return val > other.val;
    }
};

static long long dp[MAX_POS][MAX_TYPE];

void dijkstra() {
    for (int i = 0; i < a; i++) {
        for (int t = 0; t < MAX_TYPE; t++) {
            dp[i][t] = INF;
        }
    }
    int startPos = mark[0].first, startType = mark[0].second;
    dp[startPos][startType] = 0;
    priority_queue<node, vector<node>, greater<node>> pq;
    pq.push({0, startPos, startType});
    while (!pq.empty()) {
        node cur = pq.top();
        pq.pop();
        int d = cur.val, pos = cur.pos, type = cur.type;
        if (dp[pos][type] < d) continue;
        if (type == 0) {
            for (int p : z[pos]) {
                int newPos = pos + p;
                if (newPos < a && p < MAX_TYPE) {
                    if (dp[newPos][p] > d + 1) {
                        dp[newPos][p] = d + 1;
                        pq.push({d + 1, newPos, p});
                    }
                }
                newPos = pos - p;
                if (newPos >= 0 && p < MAX_TYPE) {
                    if (dp[newPos][p] > d + 1) {
                        dp[newPos][p] = d + 1;
                        pq.push({d + 1, newPos, p});
                    }
                }
            }
        } else {
            if (dp[pos][0] > d) {
                dp[pos][0] = d;
                pq.push({d, pos, 0});
            }
            if (type > blocksize) {
                for (int step = 1; pos + step * type < a; step++) {
                    int newPos = pos + step * type;
                    if (dp[newPos][0] > d + step) {
                        dp[newPos][0] = d + step;
                        pq.push({d + step, newPos, 0});
                    }
                }
                for (int step = 1; pos - step * type >= 0; step++) {
                    int newPos = pos - step * type;
                    if (dp[newPos][0] > d + step) {
                        dp[newPos][0] = d + step;
                        pq.push({d + step, newPos, 0});
                    }
                }
            } else {
                int newPos = pos + type;
                if (newPos < a && type < MAX_TYPE) {
                    if (dp[newPos][type] > d + 1) {
                        dp[newPos][type] = d + 1;
                        pq.push({d + 1, newPos, type});
                    }
                }
                newPos = pos - type;
                if (newPos >= 0 && type < MAX_TYPE) {
                    if (dp[newPos][type] > d + 1

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'void dijkstra()':
skyscraper.cpp:84:49: error: expected ')' at end of input
   84 |                     if (dp[newPos][type] > d + 1
      |                        ~                        ^
      |                                                 )
skyscraper.cpp:84:49: error: expected statement at end of input
skyscraper.cpp:84:49: error: expected '}' at end of input
skyscraper.cpp:83:53: note: to match this '{'
   83 |                 if (newPos >= 0 && type < MAX_TYPE) {
      |                                                     ^
skyscraper.cpp:84:49: error: expected '}' at end of input
   84 |                     if (dp[newPos][type] > d + 1
      |                                                 ^
skyscraper.cpp:74:20: note: to match this '{'
   74 |             } else {
      |                    ^
skyscraper.cpp:84:49: error: expected '}' at end of input
   84 |                     if (dp[newPos][type] > d + 1
      |                                                 ^
skyscraper.cpp:54:16: note: to match this '{'
   54 |         } else {
      |                ^
skyscraper.cpp:84:49: error: expected '}' at end of input
   84 |                     if (dp[newPos][type] > d + 1
      |                                                 ^
skyscraper.cpp:32:25: note: to match this '{'
   32 |     while (!pq.empty()) {
      |                         ^
skyscraper.cpp:84:49: error: expected '}' at end of input
   84 |                     if (dp[newPos][type] > d + 1
      |                                                 ^
skyscraper.cpp:22:17: note: to match this '{'
   22 | void dijkstra() {
      |                 ^