# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
462497 | fuad27 | Crocodile's Underground City (IOI11_crocodile) | C++14 | 6 ms | 460 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>
#include "crocodile.h"
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
vector<vector<pair<int, int>>> adj(N);
for(int i = 0; i < M; i++) {
int u = R[i][0], v = R[i][1];
adj[u].emplace_back(v, L[i]);
adj[v].emplace_back(u, L[i]);
}
vector<int> visited(N);
priority_queue<pair<int, int>> q;
for(int i = 0; i < K; i++) {
visited[P[i]]++;
q.emplace(0, P[i]);
}
while(!q.empty()) {
auto [d, v] = q.top();
q.pop();
if(visited[v] == 1) {
visited[v]++;
if(v == 0) return -d;
for(auto &[u, w] : adj[v])
q.emplace(d - w, u);
}
}
}
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... |