Submission #28876

#TimeUsernameProblemLanguageResultExecution timeMemory
28876kavunRace (IOI11_race)C++14
21 / 100
3078 ms12412 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; vector <pair<int,int> > adj[300000]; void dfs(int v, int d, int length, int par, int& mn, int K) { if(length == K) { mn = min(mn,d); } else if(length > K) return; for(int i = 0; i < adj[v].size(); i++) { int u = adj[v][i].first; if(u != par) dfs(u,d+1,length + adj[v][i].second,v,mn, K); } } int best_path(int N, int K, int H[][2], int L[]) { for(int i = 0; i < N-1; i++) { int v = H[i][0],u = H[i][1],l = L[i]; adj[v].push_back(make_pair(u,l)); adj[u].push_back(make_pair(v,l)); } int mn = 1e9; for(int i = 0; i < N; i++) { dfs(i,0,0,i,mn,K); } if(mn == 1e9) return -1; return mn; }

Compilation message (stderr)

race.cpp: In function 'void dfs(int, int, int, int, int&, int)':
race.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < adj[v].size(); i++)
                    ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...