Submission #756077

#TimeUsernameProblemLanguageResultExecution timeMemory
756077asdfgraceCrocodile's Underground City (IOI11_crocodile)C++17
100 / 100
750 ms101144 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; typedef long long i64; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { vector<vector<pair<int, i64>>> edges(N); for (int i = 0; i < M; ++i) { edges[R[i][1]].emplace_back(R[i][0], i64(L[i])); edges[R[i][0]].emplace_back(R[i][1], i64(L[i])); } vector<int> visited(N, 0); vector<i64> d(N, 1e18); priority_queue<pair<i64, int>> q; for (int i = 0; i < K; ++i) { visited[P[i]] = 1; d[P[i]] = 0; q.push({0, P[i]}); } while (!q.empty()) { i64 dist = -q.top().first; int node = q.top().second; q.pop(); if (visited[node] >= 2) continue; ++visited[node]; if (visited[node] < 2) continue; d[node] = dist; for (auto [next, weight] : edges[node]) { if (visited[next] < 2) { q.push({-dist - weight, next}); } } } return d[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...