# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
434841 | 2021-06-21T23:27:46 Z | illyakr | 악어의 지하 도시 (IOI11_crocodile) | C++14 | 4 ms | 3612 KB |
#include <bits/stdc++.h> #include "crocodile.h" using namespace std; vector<pair<int, int> > g[101010]; bool used[101010]; pair<int, int> ans[101010]; bool cn[101010]; int sv = -1; void dfs(int v, int sum) { if (used[v])return; if (cn[v]) { ans[v] = {0, sum}; sv = sum; return; } if (ans[v].first != -1) { // ans[v] = max(ans[v], sum); return; } used[v] = true; int Mn1 = 1010101010; int Mn2 = 1010101010; for (auto [to, c] : g[v]) { if (used[to])continue; dfs(to, sum + c); if (ans[to].first + c < Mn1) { Mn2 = Mn1; Mn1 = ans[to].first + c; } else if (ans[to].first + c < Mn2) { Mn2 = ans[to].first + c; } } ans[v] = {Mn2, sum}; used[v] = false; } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for (int i = 0; i < M; i++) { g[R[i][0] + 1].push_back({R[i][1] + 1, L[i]}); g[R[i][1] + 1].push_back({R[i][0] + 1, L[i]}); } for (int i = 0; i < K; i++) cn[P[i] + 1] = true; memset(ans, -1, sizeof(ans)); dfs(1, 0); return ans[1].first; } /** 5 4 3 0 1 2 0 2 3 3 2 1 2 4 4 1 3 4 7 5 7 2 0 2 4 0 3 3 3 2 2 2 1 10 0 1 100 0 4 7 3 4 9 1 3 14 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 3 ms | 3404 KB | Output is correct |
4 | Correct | 3 ms | 3532 KB | Output is correct |
5 | Correct | 3 ms | 3532 KB | Output is correct |
6 | Correct | 3 ms | 3532 KB | Output is correct |
7 | Correct | 3 ms | 3532 KB | Output is correct |
8 | Correct | 3 ms | 3532 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 3 ms | 3404 KB | Output is correct |
4 | Correct | 3 ms | 3532 KB | Output is correct |
5 | Correct | 3 ms | 3532 KB | Output is correct |
6 | Correct | 3 ms | 3532 KB | Output is correct |
7 | Correct | 3 ms | 3532 KB | Output is correct |
8 | Correct | 3 ms | 3532 KB | Output is correct |
9 | Correct | 4 ms | 3612 KB | Output is correct |
10 | Incorrect | 3 ms | 3404 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3404 KB | Output is correct |
2 | Correct | 2 ms | 3404 KB | Output is correct |
3 | Correct | 3 ms | 3404 KB | Output is correct |
4 | Correct | 3 ms | 3532 KB | Output is correct |
5 | Correct | 3 ms | 3532 KB | Output is correct |
6 | Correct | 3 ms | 3532 KB | Output is correct |
7 | Correct | 3 ms | 3532 KB | Output is correct |
8 | Correct | 3 ms | 3532 KB | Output is correct |
9 | Correct | 4 ms | 3612 KB | Output is correct |
10 | Incorrect | 3 ms | 3404 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |