이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
struct edge{
int to;
int cost;
};
vector<edge> graph[100003];
pll odl[100003];
ll oo=1e18+1;
priority_queue<pll,vector<pll>,greater<pll>> pq;
void Dijkstra(){
while(pq.size()){
auto [d,v]=pq.top();
pq.pop();
if (odl[v].second<d)continue;
for (auto u : graph[v]){
if (d+u.cost<odl[u.to].first){
odl[u.to].second=odl[u.to].first;
if (odl[u.to].second<oo)pq.push(make_pair(odl[u.to].second,u.to));
odl[u.to].first=d+u.cost;
}
else if (d+u.cost<odl[u.to].second){
odl[u.to].second=d+u.cost;
pq.push(make_pair(odl[u.to].second,u.to));
}
}
}
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
for (int i = 0; i<m; i++){
graph[r[i][0]].push_back({r[i][1],l[i]});
graph[r[i][1]].push_back({r[i][0],l[i]});
}
fill(odl,odl+n,make_pair(oo,oo));
for (int i = 0; i<k; i++){
pq.push({0,p[i]});
odl[p[i]]={0,0};
}
Dijkstra();
return odl[0].second;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |