제출 #556307

#제출 시각아이디문제언어결과실행 시간메모리
556307a_aguiloTraffic (IOI10_traffic)C++14
컴파일 에러
0 ms0 KiB
#include "traffic.h" #include<bits/stdc++.h> using namespace std; void dfs(int nodo, int padre, vector<vector<int>>& listaAdy, vector<vector<int>>& lista2){ for(int conexion: listaAdy[nodo]){ if(conexion != padre){ lista2[nodo].push_back(conexion); dfs(conexion, nodo, listaAdy, lista2); } } } int dfs2 (int nodo, vector<vector<int>>& listaAdy, int pop[], vector<int>& dp){ if(dp[nodo] != -1) return dp[nodo]; dp[nodo] = pop[nodo]; for(int conexion: listaAdy[nodo]){ dp[nodo]+= dfs(conexion, listaAdy, pop, dp); } return dp[nodo]; } int LocateCentre(int N, int pp[], int S[], int D[]) { vector<vector<int>> listaAdy(N); vector<vector<int>> listaAdy2(N); int SUM = pp[0]; for(int i= 1; i < N; ++i){ int a = S[i]; int b = D[i]; listaAdy[a].push_back(b); } dfs(0, -1, listaAdy, listaAdy2); vector<int> dp(N, -1); long long int SUM = dfs2(0, listaAdy2, pp, dp); pair<long long int, int> ans = make_pair(SUM+1, 0); for(int i = 0; i < n; ++i){ long long int mas_concurrida = SUM - dp[i];//lo que viene del padre for(int conexion: listaAdy2[i]){ mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo } ans = min(ans, make_pair(mas_concurrida, conexion)); } return ans.second; }

컴파일 시 표준 에러 (stderr) 메시지

traffic.cpp: In function 'int dfs2(int, std::vector<std::vector<int> >&, int*, std::vector<int>&)':
traffic.cpp:19:34: error: cannot convert 'std::vector<std::vector<int> >' to 'int'
   19 |         dp[nodo]+= dfs(conexion, listaAdy, pop, dp);
      |                                  ^~~~~~~~
      |                                  |
      |                                  std::vector<std::vector<int> >
traffic.cpp:6:24: note:   initializing argument 2 of 'void dfs(int, int, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&)'
    6 | void dfs(int nodo, int padre, vector<vector<int>>& listaAdy, vector<vector<int>>& lista2){
      |                    ~~~~^~~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:35:18: error: conflicting declaration 'long long int SUM'
   35 |    long long int SUM = dfs2(0, listaAdy2, pp, dp);
      |                  ^~~
traffic.cpp:27:8: note: previous declaration as 'int SUM'
   27 |    int SUM = pp[0];
      |        ^~~
traffic.cpp:37:23: error: 'n' was not declared in this scope
   37 |    for(int i = 0; i < n; ++i){
      |                       ^
traffic.cpp:40:62: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   40 |             mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo
      |                                                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
traffic.cpp:40:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |             mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo
      |                                                              ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
traffic.cpp:40:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   40 |             mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
traffic.cpp:40:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |             mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from traffic.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
traffic.cpp:40:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   40 |             mas_concurrida = max(mas_concurrida, dp[conexion]); //lo que viene de cada nodo
      |                                                              ^
traffic.cpp:42:50: error: 'conexion' was not declared in this scope
   42 |         ans = min(ans, make_pair(mas_concurrida, conexion));
      |                                                  ^~~~~~~~