#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n,m,T,d[500005];
vector<ii> g[500005];
priority_queue<ii> Q;
int main()
{
ios_base::sync_with_stdio(false);
//freopen("TEST.INP","r",stdin);
cin>>n>>m>>T;
int u,v,w;
while(m--)
{
cin>>u>>v>>w;
g[u].push_back(ii(v,w));
g[v].push_back(ii(u,w));
}
d[1]=1e9;
Q.push(ii(1e9,1));
while(Q.size()>0)
{
int u=Q.top().second;
int val=Q.top().first;
Q.pop();
if(d[u]==val)
for(int i=0; i<g[u].size(); i++)
{
int v=g[u][i].first;
int w=g[u][i].second;
if(d[v]<min(d[u],w))
{
d[v]=min(d[u],w);
Q.push(ii(d[v],v));
}
}
}
while(T--)
{
cin>>u;
cout<<d[u]<<"\n";
}
}
Compilation message
sightseeing.cpp: In function 'int main()':
sightseeing.cpp:29:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<g[u].size(); i++)
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
12024 KB |
Output is correct |
2 |
Correct |
11 ms |
12264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12320 KB |
Output is correct |
2 |
Correct |
11 ms |
12320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
14412 KB |
Output is correct |
2 |
Correct |
51 ms |
14412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3521 ms |
106080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |