#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
long long n,m,q,x,y,c,ans[500010];
vector<vector<pair<long long,long long>>>a;
priority_queue<pair<long long,long long>>b;
bool ok[500010];
void constructie(long long nod)
{
if(ok[nod]==true)
return;
ok[nod]=true;
for(auto z:a[nod])
{
if(min(z.second,ans[nod])>ans[z.first])
{
ans[z.first]=min(z.second,ans[nod]);
b.push(make_pair(ans[z.first],z.first));
ok[z.first]=false;
}
}
if(b.empty())
return;
long long aq=b.top().second;
b.pop();
constructie(aq);
return;
}
int main()
{
cin>>n>>m>>q;
a.resize(n+5);
for(long long i=1;i<=n;++i)
{
cin>>x>>y>>c;
a[x].push_back(make_pair(y,c));
a[y].push_back(make_pair(x,c));
}
ans[1]=100000001;
constructie(1);
ans[1]=0;
for(long long i=1;i<=q;++i)
{
cin>>x;
cout<<ans[x]<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
40 ms |
3348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
881 ms |
31980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |