Submission #963094

#TimeUsernameProblemLanguageResultExecution timeMemory
963094AmrRace (IOI11_race)C++17
21 / 100
22 ms9296 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; #define F first #define S second #define sz size() typedef long long ll; ll k,ans =1e18; const int N = 1002; vector<pair<ll,ll> > v[N]; void dfs(ll x,ll par, ll w,ll d) { if(w==k) ans = min(d,ans); for(int i = 0; i < v[x].sz; i++) { ll w2 = v[x][i].S; ll y = v[x][i].F; if(y==par) continue; dfs(y,x,w2+w,d+1); } } int best_path(int N, int K, int H[][2], int L[]) { k = K; for(int i = 0 ; i < N-1; i++) { ll x = H[i][0], y = H[i][1], w = L[i]; v[x].push_back({y,w}); v[y].push_back({x,w}); } for(int i = 0; i < N; i++) { dfs(i,-1,0,0); } if(ans!=1e18) return ans; else return -1; }

Compilation message (stderr)

race.cpp: In function 'void dfs(ll, ll, ll, ll)':
race.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i = 0; i < v[x].sz; 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...