# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984857 | 2024-05-17T07:29:00 Z | 54skyxenon | Crocodile's Underground City (IOI11_crocodile) | C++17 | 0 ms | 0 KB |
// https://oj.uz/problem/view/IOI11_crocodile #include <bits/stdc++.h> using namespace std; #define int long long vector<map<int, int>> graph; vector<bool> is_exit; vector<bool> visited; int dfs(int curr) { if (is_exit[curr]) { return 0; } vector<int> distances; for (auto [nei, weight] : graph[curr]) { if (!visited[nei]) { visited[nei] = true; distances.push_back(weight + dfs(nei)); } } sort(distances.begin(), distances.end()); return distances[1]; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; graph.resize(n); for (int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; graph[u][v] = graph[v][u] = w; } is_exit.resize(n); visited.resize(n); for (int i = 0; i < k; i++) { int p; cin >> p; is_exit[p] = true; } visited[0] = true; cout << dfs(0) << '\n'; }