이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
int min_cost[N], cost[N];
bool vis[N];
vector<pii> edges[N];
memset(vis, 0, sizeof(vis));
fill(cost, cost+N, 1e9+7);
fill(min_cost, min_cost+N, 1e9+7);
for(int i = 0; i < M; i++)
edges[R[i][0]].pb({R[i][1], L[i]}), edges[R[i][1]].pb({R[i][0], L[i]});
priority_queue<pii, vector<pii>, greater<pii>> pq;
for(int i = 0; i < K; i++)
pq.push({0, P[i]}), min_cost[P[i]] = cost[P[i]] = 0;
while(!pq.empty()) {
auto [d, x] = pq.top();
pq.pop();
if(vis[x]) continue;
vis[x] = 1;
for(auto [viz, peso] : edges[x]) {
cost[viz] = min(cost[viz], max(min_cost[viz], d + peso));
min_cost[viz] = min(min_cost[viz], d + peso);
if(cost[viz] < 1e9+7) pq.push({cost[viz], viz});
}
}
return cost[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |