답안 #995960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995960 2024-06-10T06:10:44 Z 54skyxenon 악어의 지하 도시 (IOI11_crocodile) C++17
컴파일 오류
0 ms 0 KB
// https://oj.uz/problem/view/IOI11_crocodile

/** Needed for linking!!! */
#include "crocodile.h"

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define INF (ll)1e18

vector<map<int, int>> graph;
vector<bool> is_exit;
vector<set<int>> visited;

int dijkstra() {
    vector<vector<int>> dist(graph.size(), {INF, INF});
    priority_queue<pair<int, int>> pq;

    for (int i = 0; i < graph.size(); i++) {
        if (is_exit[i]) {
            pq.push({0, i});
            dist[i][0] = dist[i][1] = 0;
        }
    }

    while (pq.size()) {
        auto [d, u] = pq.top();
        pq.pop();
        d = -d;

        if (d > dist[u][0] && d > dist[u][1]) {
            continue;
        }

        for (auto& [v, w] : graph[u]) {
            int cost = w + d;

            if (cost < dist[v][0]) {
                dist[v][0] = cost;
                pq.push({-cost, v});
            }
            else if (cost < dist[v][1]) {
                dist[v][1] = cost;
                pq.push({-cost, v});
            }
        }
    }

    return dist[0][1];
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    graph.resize(N);
    is_exit.resize(N);
    visited.resize(N);

    for (int i = 0; i < M; i++) {
        graph[R[i][0]][R[i][1]] = graph[R[i][1]][R[i][0]] = L[i];
    }

    for (int i = 0; i < K; i++) {
        is_exit[P[i]] = true;
    }
        
    return dijkstra();
}

Compilation message

crocodile.cpp: In function 'int dijkstra()':
crocodile.cpp:17:54: error: narrowing conversion of '1000000000000000000' from 'long long int' to 'int' [-Wnarrowing]
   17 |     vector<vector<int>> dist(graph.size(), {INF, INF});
      |                                                      ^
crocodile.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::map<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < graph.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~