#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));
}
}
}
while(q--)
{
int x;
cin >> x;
cout << dist[x] << endl;
}
return 0;
}
Compilation message
cats.cpp: In function 'int main()':
cats.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 |
Runtime error |
2 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
952 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
964 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1796 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
873 ms |
262144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |