Submission #419439

#TimeUsernameProblemLanguageResultExecution timeMemory
419439Emin2004Crocodile's Underground City (IOI11_crocodile)C++14
46 / 100
174 ms262148 KiB
#include "crocodile.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int, ll> #define F first #define S second const int N = 200005; const int mod = 1e9+7; vector<pii> a[N]; int DFS(int node, int par){ ll mn1 = LONG_MAX, mn2 = LONG_MAX; for(pii i : a[node]){ if(i.F == par) continue; ll cur = DFS(i.F, node) + i.S; if(cur <= mn1){ mn2 = mn1; mn1 = cur; } else if(cur < mn2) mn2 = cur; } if(mn1 == LONG_MAX || mn2 == LONG_MAX) return 0; return mn2; } 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]; ll w = l[i]; a[u].pb({v, w}); a[v].pb({u, w}); } return DFS(0, 0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...