#include<iostream>
#include<cmath>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int ll;
const ll maxn=1e5+2;
const ll mod=100000000;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,t;
cin>>n>>m>>t;
ll i,x,y,z;
vector<pair<ll,ll>>adj[n+1];
vector<ll>temp[n+1];
for(i=0;i<m;i++)
{
cin>>x>>y>>z;
adj[x].push_back({y,z});
adj[y].push_back({x,z});
temp[x].push_back(y);
temp[y].push_back(x);
}
ll qua[n+1];
for(i=1;i<=n;i++)
{
qua[i]=maxn;
}
ll visited[n+1]={0};
ll f[n+1]={-1};
queue<pair<ll,ll>>q;
q.push({0,1});
while(!q.empty())
{
ll a=q.front().second;
q.pop();
if(visited[a])
continue;
visited[a]=1;
for(auto u: adj[a])
{
ll b=u.first;
ll w=u.second;
qua[b]=min(w,qua[a]);
f[b]=max(f[b],qua[b]);
q.push({-qua[b],b});
}
}
/*for(i=1;i<=n;i++)
{
cout<<qua[i]<<" ";
}
cout<<"\n";
for(i=1;i<=n;i++)
{
cout<<f[i]<<" ";
}
*/
for(i=0;i<t;i++)
{
ll ab;
cin>>ab;
cout<<f[ab]<<"\n";
}
cerr<<"\nTime elapsed:"<< 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
8684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3473 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |