답안 #940107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
940107 2024-03-07T05:39:29 Z Darren0724 Cities (BOI16_cities) C++17
0 / 100
266 ms 51604 KB
#include <bits/stdc++.h>
using namespace std;
#define LCBorz ios_base::sync_with_stdio(false); cin.tie(0);
#define int long long 
#define all(x) x.begin(), x.end()
#define endl '\n'
const int N=200005;
const int INF=1e18;
int n,k,m;
vector<int> s;
vector<pair<int,int>> adj[N];
vector dis(4,vector<int>(N,INF));
void dijk(int s,vector<int> &dis){
    dis[s]=0;
    priority_queue<pair<int,int>> pq;
    pq.push({0,s});
    while(pq.size()){
        auto [dis1,a]=pq.top();
        pq.pop();
        dis1=-dis1;
        if(dis1!=dis[a])continue;
        for(auto [c,d]:adj[a]){
            int cost=dis1+d;
            if(dis[c]>cost){
                dis[c]=cost;
                pq.push({-dis[c],c});
            }
        }
    }
}
int32_t main() {
    LCBorz;
    cin>>n>>k>>m;    
    for(int i=0;i<k;i++){
        int p;cin>>p;
        s.push_back(p);
    }
    for(int i=0;i<m;i++){
        int a,b,c;cin>>a>>b>>c;
        adj[a].push_back({b,c});
        adj[b].push_back({a,c});
    }
    for(int i=0;i<k;i++){
        dijk(s[i],dis[i]);
    }
    int ans=INF;
    for(int i=1;i<=n;i++){
        ans=min(ans,dis[0][i]+dis[1][i]+dis[2][i]);
    }
    cout<<ans<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 180 ms 27868 KB Output is correct
2 Correct 195 ms 28464 KB Output is correct
3 Correct 69 ms 18588 KB Output is correct
4 Correct 73 ms 23776 KB Output is correct
5 Incorrect 186 ms 27820 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 12892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 253 ms 27696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 266 ms 51604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -