답안 #48324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
48324 2018-05-11T17:11:04 Z marvenlee 관광 (NOI14_sightseeing) C++14
9 / 25
3500 ms 65112 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 u=pq.top().second;
        if(dist[u]!=pq.top().first) continue;
        pq.pop();
        for(int i=0;i<graph[u].size();i++)
        {
            if(dist[graph[u][i].first]< min(dist[u],graph[u][i].second))
            {
                dist[graph[u][i].first]=min(dist[u],graph[u][i].second);
                pq.push(ii(dist[graph[u][i].first],graph[u][i].first));
            }
        }
    }
    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:29: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 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 436 KB Output is correct
2 Correct 10 ms 436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3541 ms 3308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3541 ms 65112 KB Time limit exceeded
2 Halted 0 ms 0 KB -