Submission #1007471

#TimeUsernameProblemLanguageResultExecution timeMemory
1007471ezzzayRace (IOI11_race)C++14
9 / 100
53 ms16412 KiB
#include "race.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define ff first #define ll long long #define ss second const int M=2e5+5; ll ans=INT_MAX; vector<pair<ll,ll>>v[M]; bool vis[M]; ll Z; vector<ll> fun(ll a){ vis[a]=1; vector<ll>dp(150); for(ll i=0;i<=Z;i++)dp[i]=INT_MAX; dp[0]=0; for(auto p:v[a]){ ll b=p.ff; ll c=p.ss; if(vis[b]==0){ vector<ll>vc=fun(b); for(ll i=0;i<=Z;i++){ ans=min(ans,dp[i]+vc[Z-i]+2); } for(int i=0;i<=Z-c;i++){ dp[i+c]=min(dp[i+c],vc[i]+1); } } } ans=min(ans,dp[Z]); return dp; } int best_path(int N, int K, int H[][2], int L[]){ Z=K; for(int i=0;i<N-1;i++){ int a=H[i][0]; int b=H[i][1]; int c=L[i]; v[a].pb({b,c}); v[b].pb({a,c}); } fun(0); if(ans==INT_MAX)return -1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...