#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define F first
#define S second
#define itr ::iterator
typedef pair<int,int> pii;
const int MAX=1e5+99;
vector<pii> vec[MAX];
int V,E,Q,X,Y,Z,res[MAX];
void dijkstra()
{
pii cur;
priority_queue<pii> pq;
pq.push(mp(MAX,1));
res[1]=MAX;
while(! pq.empty())
{
cur=pq.top();
pq.pop();
if(cur.first < res[cur.second])
continue;
for(auto A:vec[cur.second])
if(min(cur.first,A.second)>res[A.first])
{
res[A.first]=min(cur.first,A.second);
pq.push(mp(res[A.first],A.first));
}
}
return ;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>V>>E>>Q;
while(E--)
{
cin>>X>>Y>>Z;
vec[X].pb(mp(Y,Z));
vec[Y].pb(mp(X,Z));
}
dijkstra();
while(Q--)
{
cin>>X;
cout<<res[X]<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2680 KB |
Output is correct |
2 |
Correct |
3 ms |
2840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2988 KB |
Output is correct |
2 |
Correct |
4 ms |
3036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
6144 KB |
Output is correct |
2 |
Correct |
41 ms |
6144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
6 ms |
6144 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |