이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << x << endl;
#define raya cout << "===========================" << endl;
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const int N = 1e5+5;
int n, m;
int vis[N];
vector<pair<int,int>> g[N];
int travel_plan(int nn, int mm, int R[][2], int L[], int K, int P[]){
n = nn;
m = mm;
for(int i=0; i<m; ++i){
g[R[i][0]].push_back({R[i][1], L[i]});
g[R[i][1]].push_back({R[i][0], L[i]});
}
priority_queue<pair<ll,int>> pq;
for(int i=0; i<K; ++i){
pq.push({0, P[i]});
vis[P[i]] = 1;
}
while(!pq.empty()){
auto w = -pq.top().first; auto u = pq.top().second;
pq.pop();
if(!vis[u]){
vis[u] = 1;
continue;
}
if(vis[u] == 2){
continue;
}
if(u == 0){
return w;
}
vis[u] = 2;
for(auto v : g[u]){
if(vis[v.first] == 2){
continue;
}
pq.push({-(w+v.second), v.first});
}
}
assert(0);
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |