Submission #1028611

# Submission time Handle Problem Language Result Execution time Memory
1028611 2024-07-20T06:05:24 Z vjudge1 Jakarta Skyscrapers (APIO15_skyscraper) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 30010, M = 30010;
int n, m, b[M], p[M], dist[N];
bool mark[N];
vector<int> vec[N];


int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i ++){
        cin >> b[i] >> p[i];
        vec[b[i]].push_back(p[i]);
    }
    for (int i = 0; i < n; i ++){
        sort(vec[i].begin(), vec[i].end());
        vec[i].resize(unique(vec[i].begin(), vec[i].end()) - vec[i].begin());
    }

    memset(dist, 63, sizeof dist);
    dist[b[0]] = 0;

    for (int ii = 0; ii < n; ii ++){
        int v = -1;
        for (int j = 0; j < n; j ++)
            if (!mark[j] and (v == -1 or dist[v] > dist[j]))
                v = j;

        if (v == b[1]) break;

        mark[v] = 1;
        for (int d : vec[v]){
            if (!exist[v][d]) continue;
            for (int i = 1; v + d * i < n; i ++)
                dist[v + d * i] = min(dist[v + d * i], dist[v] + i);
            for (int i = 1; v - d * i >= 0; i ++)
                dist[v - d * i] = min(dist[v - d * i], dist[v] + i);
        }
    }

    if (dist[b[1]] > 1e9)
        dist[b[1]] = -1;
    cout << dist[b[1]] << endl;
}

Compilation message

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:34:18: error: 'exist' was not declared in this scope; did you mean 'exit'?
   34 |             if (!exist[v][d]) continue;
      |                  ^~~~~
      |                  exit