Submission #64661

#TimeUsernameProblemLanguageResultExecution timeMemory
64661zetapiCrocodile's Underground City (IOI11_crocodile)C++14
46 / 100
870 ms263168 KiB
#include <crocodile.h> #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e6; const int INF=1e12; vector<pii> vec[MAX]; ll dp[MAX]; void dfs(int node,int par) { if(vec[node].size()==1 and vec[node][0].first==par) return ; int f=INF,s=INF; for(auto A:vec[node]) { if(A.first==par) continue; dfs(A.first,node); if(dp[A.first]+A.second<s) s=dp[A.first]+A.second; if(f>s) swap(f,s); } dp[node]=s; return ; } int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) { for(int A=0;A<M;A++) { vec[R[A][0]].pb(mp(R[A][1],L[A])); vec[R[A][1]].pb(mp(R[A][0],L[A])); } for(int A=0;A<N;A++) { if(vec[A].size()>1) { dfs(A,-1); return dp[A]; } } } /*signed main() { ios_base::sync_with_stdio(false); return 0; }*/

Compilation message (stderr)

crocodile.cpp:14:15: warning: overflow in implicit constant conversion [-Woverflow]
 const int INF=1e12;
               ^~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...