# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
943992 | Amaarsaa | Crocodile's Underground City (IOI11_crocodile) | C++14 | 1 ms | 4444 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair < ll, ll >;
const ll INF = 1e18;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
ll i, x, c, y, s, p, X;
vector < pair < ll,ll > > adj[N + 2];
for (i = 0; i < M; i ++) {
x = R[i][0];
y = R[i][1];
adj[x].push_back({y, L[i]});
adj[y].push_back({x, L[i]});
}
priority_queue < pll, vector < pll > , greater < pll > > pq;
ll D[N + 2][2];
for (i = 0; i < N; i ++) D[i][1] = INF, D[i][0] = INF;
for (i = 0; i < K; i ++) {
pq.push({0, P[i]});
D[P[i]][0] = D[P[i]][1] = 0;
}
while(!pq.empty()) {
x = pq.top().second;
c = pq.top().first;
pq.pop();
if ( D[x][1] != c) continue;
for ( pair < ll, ll > & pa : adj[x]) {
X = pa.first;
s = c + pa.second;
p = D[X][1];
if ( s < D[X][0]) {
if ( D[X][0] < INF && D[X][1] != D[X][0]) {
D[X][1]= D[X][0];
pq.push({D[X][1], X});
}
D[X][0] = s;
}
else {
if ( s < D[x][1]) {
D[X][1] = s;
pq.push({D[X][1], X});
}
}
}
}
return D[0][1];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |