답안 #852328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
852328 2023-09-21T15:25:23 Z uped 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
1 ms 4440 KB
#include "crocodile.h"

#include <bits/stdc++.h>

using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    vector<vector<pair<int, int>>> adj(N);
    for (int i = 0; i < M; ++i) {
        adj[R[i][0]].emplace_back(R[i][1], L[i]);
        adj[R[i][1]].emplace_back(R[i][0], L[i]);
    }
    vector<bool> is_exit(N);
    for (int i = 0; i < K; ++i) {
        is_exit[P[i]] = true;
    }

    priority_queue<pair<int, int>> pq;
    vector<int> distance(N, INT32_MAX);
    pq.emplace(0, 0);
    distance[0] = 0;
    int ans = INT32_MAX;
    while (!pq.empty()) {
        auto [dist, a] = pq.top(); pq.pop();
        if (-dist != distance[a]) continue;

        pair<int,int> min {-1, -1};
        for (auto [b, w] : adj[a]) {
            if (is_exit[b]) {
                if (min.first == -1 || w < min.first) {
                    min.second = min.first;
                    min.first = w;
                } else if (min.second == -1 || w < min.second) {
                    min.second = w;
                }
            } else if (distance[a] + w < distance[b]) {
                distance[b] = distance[a] + w;
                pq.emplace(-distance[b], b);
            }
        }
        if (min.second != -1) {
            ans = ::min(ans, distance[a] + min.second);
        }
    }
    return ans;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:24:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   24 |         auto [dist, a] = pq.top(); pq.pop();
      |              ^
crocodile.cpp:28:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |         for (auto [b, w] : adj[a]) {
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -