# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
552594 | 2022-04-23T11:40:28 Z | SAAD | Crocodile's Underground City (IOI11_crocodile) | C++17 | 2000 ms | 340 KB |
#define F first #define S second #include <algorithm> #include <math.h> #include <vector> #include <iostream> using namespace std; vector < pair < long long , long long >> x[1002]; vector <int> ex; long long sm[1002]; bool exi[1002]; bool visa[1002]; long long dfs( int a ) { if (visa[a]) return 1e17; visa[a] = true; if (exi[a]) return 0; sm[a] = 1e17; for (int i = 0; i < x[a].size(); i++) { sm[a] = min(sm[a], dfs(x[a][i].S)+x[a][i].F); } return sm[a]; } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for (int i = 0; i < N; i++) { x[R[i][0]].push_back({ L[i],R[i][1] }); x[R[i][1]].push_back({ L[i],R[i][0] }); } for (int i = 0; i < K; i++) { ex.push_back(P[i]); exi[P[i]] = true; } dfs(0); bool th = true; int a = 0; long long mn = 1e18, idx = 0 , res = 0; while (!exi[a]) { th = true; mn = 1e18; idx = 0; for (int i = 0; i < x[a].size(); i++) { long long cst = sm[x[a][i].S] + x[a][i].F; if (sm[a] == cst&&th) { th = false; continue; } if (mn > cst) { mn = cst; idx = i; } } res += x[a][idx].F; a = x[a][idx].S; } return res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2065 ms | 340 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |