답안 #48323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48323 2018-05-11T17:07:16 Z marvenlee 관광 (NOI14_sightseeing) C++14
9 / 25
3500 ms 105780 KB
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;

int main()
{
    int n,m,q;
    cin >> n >> m >> q;
    vector< vector<ii> >graph;
    graph.assign(n+1,vector<ii>());
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        graph[u].push_back(ii(v,w));
        graph[v].push_back(ii(u,w));
    }
    priority_queue<ii , vector<ii> , greater<ii> > pq;
    vector<int> dist (n+1,0);
    dist[1]=2e9;
    pq.push(ii(2e9,1));
    while(!pq.empty())
    {
        int d=pq.top().first;
        int u=pq.top().second;
        if(dist[u]!=d) continue;
        pq.pop();
        for(int i=0;i<graph[u].size();i++)
        {
            int v=graph[u][i].first, w=graph[u][i].second;
            if(dist[v]< min(dist[u],w))
            {
                dist[v]=min(dist[u],w);
                pq.push(ii(dist[v],v));
            }
        }
    }
    for(int i=0;i<q;i++)
    {
        int x;
        cin >> x;
        cout << dist[x] << endl;
    }
    return 0;
}

Compilation message

sightseeing.cpp: In function 'int main()':
sightseeing.cpp:30:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<graph[u].size();i++)
                     ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 904 KB Output is correct
2 Correct 10 ms 904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3535 ms 4648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3540 ms 105780 KB Time limit exceeded
2 Halted 0 ms 0 KB -