Submission #48324

#TimeUsernameProblemLanguageResultExecution timeMemory
48324marvenleeSightseeing (NOI14_sightseeing)C++14
9 / 25
3541 ms65112 KiB
#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 (stderr)

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++)
                     ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...