답안 #905124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
905124 2024-01-12T15:41:32 Z Macker 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
1 ms 4440 KB
#include "crocodile.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")


int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    vector<vector<pair<int, int>>> adj(N);
    vector<bool> bl(N, 0);
    vector<int> dist(N, INT_MAX/2);
    for (int i = 0; i < M; i++) {
        adj[R[i][0]].push_back({R[i][1], L[i]});
        adj[R[i][1]].push_back({R[i][0], L[i]});
    }

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    for (int i = 0; i < K; i++) {
        q.push({0, P[i]});
        dist[P[i]] = 0;
        bl[P[i]] = 1;
    }
    
    while(q.size()){
        auto [d, a] = q.top(); q.pop();
        if(!bl[a]){
            bl[a] = 1;
            continue;
        }
        dist[a] = min(d, dist[a]);
        for (auto &[b, c] : adj[a]) {
            if(dist[b] > dist[a] + c){
                //dist[b] = dist[a] + c;
                q.push({dist[a] + c, b});
            }
        }
    }
    
    return dist[0];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:31:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |         auto [d, a] = q.top(); q.pop();
      |              ^
crocodile.cpp:37:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   37 |         for (auto &[b, c] : 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 -