# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
479492 | 2021-10-12T02:45:45 Z | Yuisuyuno | Crocodile's Underground City (IOI11_crocodile) | C++14 | 0 ms | 0 KB |
//Nguyen Huu Hoang Minh #include <bits/stdc++.h> #include "crocodile.h" #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define reset(x) memset(x, 0,sizeof(x)) #define pb push_back #define mp make_pair #define fi first #define se second #define N 100005 #define remain(x) if (x > MOD) x -= MOD #define ii pair<int, int> #define iiii pair< ii , ii > #define viiii vector< iiii > #define vi vector<int> #define vii vector< ii > #define bit(x, i) (((x) >> (i)) & 1) #define Task "test" #define int long long using namespace std; typedef long double ld; const int inf = 1e10; const int minf = -1e10; vector<ii> g[N]; int dp[N]; void dfs(int u, int pre){ vector<int> ans; for(auto i : g[u]){ int v = i.fi; int uv = i.se; if (v!=pre){ dfs(v,u); ans.pb(dp[v]+uv); } } sort(all(ans)); dp[u] = ans[1]; } int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){ for(int i=0; i<m; i++){ int u = r[i][0]; int v = r[i][1]; int z = l[i]; g[u].pb(ii(v,z)); g[v].pb(ii(u,z)); } dfs(0,0); return dp[0]; }