Submission #369226

#TimeUsernameProblemLanguageResultExecution timeMemory
369226chubyxdxdRace (IOI11_race)C++14
Compilation error
0 ms0 KiB
#include "race.h" #include <vector> #include <stdio.h> #define sc second #define ff first /*#include <stdio.h> #include <stdlib.h> #define MAX_N 500000 static int N, K; static int H[MAX_N][2]; static int L[MAX_N]; static int solution; */ using namespace std; typedef pair<int,int> ii; int mini=1e9; int k; /*inline void my_assert(int e) {if (!e) abort();} void read_input() { int i; my_assert(2==scanf("%d %d",&N,&K)); for(i=0; i<N-1; i++) my_assert(3==scanf("%d %d %d",&H[i][0],&H[i][1],&L[i])); my_assert(1==scanf("%d",&solution)); } */ vector<vector<ii>> G; void dfs(int node,int pad,int sum,int num){ if(sum==k && mini>num){ mini=num; return; } if(sum>=k)return; for(auto i:G[node]){ if(i.ff==pad)continue; if(sum+i.sc>k || num+1>=mini)continue; dfs(i.ff,node,sum+i.sc,num+1); } } int best_path(int N, int K, int H[][2], int L[]) { k=K; for(int i=0;i<N-1;i++){ int a=H[i][0]; int b=H[i][1]; G[a].emplace_back(vector<ii>{b}); G[b].emplace_back(vector<ii>{a}); } mini=1e9; for(int i=0;i<N;i++){ dfs(i,i,0,0); } if(mini==1e9)mini=-1; return mini; } /* int main() { int ans; read_input(); ans = best_path(N,K,H,L); if(ans==solution) printf("Correct.\n"); else printf("Incorrect. Returned %d, Expected %d.\n",ans,solution); return 0; } */

Compilation message (stderr)

race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:50:34: warning: narrowing conversion of 'b' from 'int' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wnarrowing]
   50 |     G[a].emplace_back(vector<ii>{b});
      |                                  ^
race.cpp:51:34: warning: narrowing conversion of 'a' from 'int' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wnarrowing]
   51 |     G[b].emplace_back(vector<ii>{a});
      |                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<int, int>; _Args = {std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >}; _Tp = std::pair<int, int>]':
/usr/include/c++/9/bits/alloc_traits.h:482:2:   required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<int, int>; _Args = {std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >}; _Tp = std::pair<int, int>; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<std::pair<int, int> >]'
/usr/include/c++/9/bits/vector.tcc:115:30:   required from 'void std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >}; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
race.cpp:50:36:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: no matching function for call to 'std::pair<int, int>::pair(std::vector<std::pair<int, int> >)'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:436:9: note: candidate: 'template<class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>)'
  436 |         pair(tuple<_Args1...>&, tuple<_Args2...>&,
      |         ^~~~
/usr/include/c++/9/bits/stl_pair.h:436:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   'std::vector<std::pair<int, int> >' is not derived from 'std::tuple<_Tps ...>'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:375:9: note: candidate: 'template<class ... _Args1, class ... _Args2> std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>)'
  375 |         pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
      |         ^~~~
/usr/include/c++/9/bits/stl_pair.h:375:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 3 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:370:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&)'
  370 |  explicit constexpr pair(pair<_U1, _U2>&& __p)
      |                     ^~~~
/usr/include/c++/9/bits/stl_pair.h:370:21: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   'std::vector<std::pair<int, int> >' is not derived from 'std::pair<_T1, _T2>'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:360:12: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&)'
  360 |  constexpr pair(pair<_U1, _U2>&& __p)
      |            ^~~~
/usr/include/c++/9/bits/stl_pair.h:360:12: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   'std::vector<std::pair<int, int> >' is not derived from 'std::pair<_T1, _T2>'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:350:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&)'
  350 |  explicit constexpr pair(_U1&& __x, _U2&& __y)
      |                     ^~~~
/usr/include/c++/9/bits/stl_pair.h:350:21: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:341:12: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&)'
  341 |  constexpr pair(_U1&& __x, _U2&& __y)
      |            ^~~~
/usr/include/c++/9/bits/stl_pair.h:341:12: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:332:17: note: candidate: 'template<class _U2, typename std::enable_if<_CopyMovePair<false, int, _U2>(), bool>::type <anonymous> > std::pair<_T1, _T2>::pair(const _T1&, _U2&&)'
  332 |        explicit pair(const _T1& __x, _U2&& __y)
      |                 ^~~~
/usr/include/c++/9/bits/stl_pair.h:332:17: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:325:18: note: candidate: 'template<class _U2, typename std::enable_if<_CopyMovePair<true, int, _U2>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&)'
  325 |        constexpr pair(const _T1& __x, _U2&& __y)
      |                  ^~~~
/usr/include/c++/9/bits/stl_pair.h:325:18: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:318:27: note: candidate: 'template<class _U1, typename std::enable_if<_MoveCopyPair<false, _U1, int>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)'
  318 |        explicit constexpr pair(_U1&& __x, const _T2& __y)
      |                           ^~~~
/usr/include/c++/9/bits/stl_pair.h:318:27: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:311:18: note: candidate: 'template<class _U1, typename std::enable_if<_MoveCopyPair<true, _U1, int>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)'
  311 |        constexpr pair(_U1&& __x, const _T2& __y)
      |                  ^~~~
/usr/include/c++/9/bits/stl_pair.h:311:18: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:304:17: note: candidate: 'constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>&&) [with _T1 = int; _T2 = int]'
  304 |       constexpr pair(pair&&) = default;
      |                 ^~~~
/usr/include/c++/9/bits/stl_pair.h:304:22: note:   no known conversion for argument 1 from 'std::vector<std::pair<int, int> >' to 'std::pair<int, int>&&'
  304 |       constexpr pair(pair&&) = default;
      |                      ^~~~~~
/usr/include/c++/9/bits/stl_pair.h:303:17: note: candidate: 'constexpr std::pair<_T1, _T2>::pair(const std::pair<_T1, _T2>&) [with _T1 = int; _T2 = int]'
  303 |       constexpr pair(const pair&) = default;
      |                 ^~~~
/usr/include/c++/9/bits/stl_pair.h:303:22: note:   no known conversion for argument 1 from 'std::vector<std::pair<int, int> >' to 'const std::pair<int, int>&'
  303 |       constexpr pair(const pair&) = default;
      |                      ^~~~~~~~~~~
/usr/include/c++/9/bits/stl_pair.h:300:21: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&)'
  300 |  explicit constexpr pair(const pair<_U1, _U2>& __p)
      |                     ^~~~
/usr/include/c++/9/bits/stl_pair.h:300:21: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   'std::vector<std::pair<int, int> >' is not derived from 'const std::pair<_T1, _T2>'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:291:19: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<int, _U1>::value) || (! std::is_same<int, _U2>::value)), int, int>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&)'
  291 |         constexpr pair(const pair<_U1, _U2>& __p)
      |                   ^~~~
/usr/include/c++/9/bits/stl_pair.h:291:19: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   'std::vector<std::pair<int, int> >' is not derived from 'const std::pair<_T1, _T2>'
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:269:26: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() && (! _ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&)'
  269 |       explicit constexpr pair(const _T1& __a, const _T2& __b)
      |                          ^~~~
/usr/include/c++/9/bits/stl_pair.h:269:26: note:   template argument deduction/substitution failed:
In file included from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/vector:64,
                 from race.cpp:2:
/usr/include/c++/9/ext/new_allocator.h:145:20: note:   candidate expects 2 arguments, 1 provided
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/9/bits/stl_algobase.h:64,
                 from /usr/include/c++/9/vector:60,
                 from race.cpp:2:
/usr/include/c++/9/bits/stl_pair.h:260:17: note: candidate: 'template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() &&