Submission #385260

#TimeUsernameProblemLanguageResultExecution timeMemory
385260Pichon5Crocodile's Underground City (IOI11_crocodile)C++17
46 / 100
154 ms262148 KiB
#include "crocodile.h" #include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second using namespace std; vector<vector<pair<int,int> > >G; int dp[1005]; void dfs(int nodo,int p){ vi v; for(auto it : G[nodo]){ if(it.F==p)continue; dfs(it.F,nodo); v.pb(dp[it.F]+it.S); } sort(v.begin(),v.end()); if(G[nodo].size()==1){ dp[nodo]=0; }else{ dp[nodo]=v[1]; } } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { //R[i][0] --- R[i][1] con peso L[i] G.assign(N+1,vector<pair<int,int> >()); for(int i=0;i<M;i++){ int a=R[i][0],b=R[i][1],w=L[i]; G[a].pb({b,w}); G[b].pb({a,w}); } dfs(0,-1); return dp[0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...