# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1153837 | murpyl | Crocodile's Underground City (IOI11_crocodile) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pi = pair<int,int>;
#define endl "\n"
#define mp make_pair
void setIO(string name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
if(sz(name)){
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
vector<vector<pi>> adj(n);
for (int i = 0; i < m; i++){
adj[r[i][0]].pb({r[i][1], l[i]});
adj[r[i][1]].pb({r[i][0], l[i]});
}
vector<pi> dist(n, {INT_MAX, INT_MAX});
priority_queue<pi, vector<pi>, greater<pi>> pq;
for (int i = 0; i < k; i++){
pq.push({0, p[i]});
dist[p[i]] = {0, 0};
}
while (!pq.empty()){
auto [d, v] = pq.top();
pq.pop();
if (dist[v].second < d) continue;
for (auto [u, w] : adj[v]){
int new_weight = d+w;
if (new_weight < dist[u].first){
pq.push({dist[u].first, u});
dist[u] = {new_weight, dist[v].second+1};
}
else if (new_weight < dist[u].second){
pq.push({dist[u].second, u});
dist[u].second = new_weight;
}
}
}
return dist[0].second;
}
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... |