# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
392813 | 2021-04-21T19:23:57 Z | Aryan_Raina | Crocodile's Underground City (IOI11_crocodile) | C++14 | 1 ms | 204 KB |
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define ar array int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) { vector<ar<int,2>> g[n]; for (int i = 0; i < m; i++) { g[R[i][0]].push_back({L[i], R[i][1]}); g[R[i][1]].push_back({L[i], R[i][0]}); } priority_queue<ar<int,2>, vector<ar<int,2>>, greater<ar<int,2>>> pq; vector<int> dist(n, -1); for (int i = 0; i < k; i++) pq.push({0,P[i]}); while (!pq.empty()) { int u = pq.top()[1], d = pq.top()[0]; pq.pop(); if (dist[u] != -1) continue; dist[u] = d; for (auto v : g[u]) if (dist[v[1]] == -1) { pq.push({d + v[0], v[1]}); } } for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end()); int u = 0, pu = -1, res = 0; while (dist[u] != 0) { for (int i = 1; i < g[u].size(); i++) { auto v = g[u][i]; if (v[1] == pu) continue; res += v[0]; pu = u; u = v[1]; break; } } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |