Submission #295950

#TimeUsernameProblemLanguageResultExecution timeMemory
295950BadrangiikhRace (IOI11_race)C++14
21 / 100
97 ms4740 KiB
#include "race.h" #include<bits/stdc++.h> using namespace std; int n , x , y , z , k , ans = 10000 ; vector < int > vec [ 1005 ] ; map < pair < int , int > , int > mp ; void go ( int chi , int par , int len , int depth ) { if ( len == k ) { ans = min ( ans , depth ) ; } for ( int i = 0 ; i < vec [ chi ] . size ( ) ; i ++ ) { if ( vec [ chi ] [ i ] == par ) continue ; go ( vec [ chi ] [ i ] , chi , len + mp [ { vec [ chi ] [ i ] , chi } ] , depth + 1 ) ; } return ; } int best_path(int N, int K, int H[][2], int L[]) { k = K ; for ( int i = 0 ; i < N - 1 ; i ++ ) { vec [ H [ i ] [ 0 ] ] . push_back ( H [ i ] [ 1 ] ) ; vec [ H [ i ] [ 1 ] ] . push_back ( H [ i ] [ 0 ] ) ; mp [ { H [ i ] [ 0 ] , H [ i ] [ 1 ] } ] = L [ i ] ; mp [ { H [ i ] [ 1 ] , H [ i ] [ 0 ] } ] = L [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { go ( i , -1 , 0 , 0 ) ; } if ( ans == 10000 ) return -1 ; else return ans ; }

Compilation message (stderr)

race.cpp: In function 'void go(int, int, int, int)':
race.cpp:13:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for ( int i = 0 ; i < vec [ chi ] . 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...