Submission #294762

#TimeUsernameProblemLanguageResultExecution timeMemory
294762BadrangiikhRace (IOI11_race)C++14
9 / 100
36 ms2936 KiB
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
 
int n , x , y , z , *l , k , ans ;
vector < int > vec [ 1005 ] ;

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 + l [ vec [ chi ] [ i ] ] , depth + 1 ) ;
    }
    return ;
}

int best_path(int N, int K, int H[][2], int L[])  {
  k = K ;
  l = L ;
  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 ] ) ;
    }
    ans = 10001 ;
    for ( int i = 0 ; i < N ; i ++ ) {
        go ( i , -1 , 0 , 0 ) ;
    }
    if ( ans == 10001 ) return -1 ;
    else return ans ;
}

Compilation message (stderr)

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