# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
984894 | 2024-05-17T08:02:04 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; vector<map<int, int>> graph; vector<bool> is_exit; vector<bool> visited; // void travel_plan(int, int, int (*) [2], int*, int, int*); 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]; } void travel_plan(int N, int M, int* R[2], int* L, int K, int* P) { graph.resize(N); is_exit.resize(N); visited.resize(N); for (int i = 0; i < M; i++) { graph[R[i][0]][R[i][1]] = graph[R[i][1]][R[i][0]] = L[i]; } for (int i = 0; i < K; i++) { is_exit[P[i]] = true; } visited[0] = true; cout << dfs(0) << '\n'; } // int main() {}