Submission #753304

#TimeUsernameProblemLanguageResultExecution timeMemory
753304acceptifyCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
523 ms71068 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<pair<int, int>> adj[N]; for (int i = 0; i < M; i++) { adj[R[i][0]].push_back({L[i], R[i][1]}); adj[R[i][1]].push_back({L[i], R[i][0]}); } int vis[N]; for (int i = 0; i < N; i++) vis[i] = 0; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; for (int i = 0; i < K; i++) pq.push({0, P[i]}), vis[P[i]] = 1; while (!pq.empty()) { int d = pq.top().first, p = pq.top().second; pq.pop(); vis[p]++; if (vis[p] == 2) { if (p == 0) return d; for (auto [w, x] : adj[p]) pq.push({d + w, x}); } } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...