Submission #294756

#TimeUsernameProblemLanguageResultExecution timeMemory
294756BadrangiikhRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include<bits/stdc++.h> using namespace std; int n , x , y , z , *l ; 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 ] ) ; } int ans = 1001 ; for ( int i = 0 ; i < N ; i ++ ) { go ( i , -1 , 0 , 0 ) ; } if ( ans == 1001 ) return -1 ; else return ans ; }

Compilation message (stderr)

race.cpp: In function 'void go(int, int, int, int)':
race.cpp:9:17: error: 'k' was not declared in this scope
    9 |     if ( len == k ) {
      |                 ^
race.cpp:10:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |         ans = min ( ans , depth ) ;
      |         ^~~
      |         abs
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 ++ ) {
      |                       ~~^~~~~~~~~~~~~~~~~~~~~~~~
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:20:3: error: 'k' was not declared in this scope
   20 |   k = K ;
      |   ^