Submission #223280

#TimeUsernameProblemLanguageResultExecution timeMemory
223280wendy_virgoRace (IOI11_race)C++14
0 / 100
8 ms5888 KiB
#include <bits/stdc++.h> using namespace std; template<typename TH> void _dbg(const char* sdbg, TH h) { cerr << sdbg << " = " << h << "\n"; } template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) { while (*sdbg != ',') cerr << *sdbg++; cerr << " = " << h << ","; _dbg(sdbg + 1, t...); } #define db(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #define chkpt cerr << "--- Checkpoint here ---\n"; const int N=2e5+5,K=1e6+6,INF=1e9; struct Edge{ int u,v,w; int Adj(int x){ return u^v^x; } }; int n,k; Edge edgeList[N]; vector<int> g[N]; int d[5005][5005],f[5005][5005]; void DFS(int u,int fa,int r){ for(int id:g[u]){ int v=edgeList[id].Adj(u); if(v!=fa){ d[r][v]=d[r][u]+edgeList[id].w; f[r][v]=f[r][u]+1; DFS(v,u,r); } } } void Sub2(){ for(int i=1;i<=n;++i){ DFS(i,-1,i); } int ans=INF; for(int i=1;i<=n;++i){ for(int j=i+1;j<=n;++j){ if(d[i][j]==k){ ans=min(ans,f[i][j]); } } } cout<<(ans==INF?-1:ans); } int best_path(int N,int K,int H[][2],int L[]) { n=N; k=K; for(int i=0;i<=n-2;++i){ int u=H[i][0]+1,v=H[i][1]+1; g[u].push_back(i+1); g[v].push_back(i+1); edgeList[i+1]={u,v,0}; } for(int i=0;i<=n-2;++i){ edgeList[i+1].w=L[i]; } Sub2(); } //int main() //{ // freopen("IOI11_race.inp","r",stdin); // ios_base::sync_with_stdio(0); // cin.tie(0); // cin>>n>>k; // for(int i=1;i<=n-1;++i){ // int u,v; // cin>>u>>v; // u++; // v++; // g[u].push_back(i); // g[v].push_back(i); // edgeList[i]={u,v,0}; // } // for(int i=1;i<=n-1;++i){ // cin>>edgeList[i].w; // } // Sub2(); // return 0; //}

Compilation message (stderr)

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:77:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...