제출 #553971

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

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

traffic.cpp: In function 'int dfs(int, int, std::vector<std::vector<int> >&, int*, std::vector<std::vector<int> >&)':
traffic.cpp:10:79: error: cannot convert 'std::vector<std::vector<int> >' to 'int*'
   10 |         if(conexion != padre) dp[nodo][padre]+= dfs(nodo, conexion, listaAdy, dp);
      |                                                                               ^~
      |                                                                               |
      |                                                                               std::vector<std::vector<int> >
traffic.cpp:6:66: note:   initializing argument 4 of 'int dfs(int, int, std::vector<std::vector<int> >&, int*, std::vector<std::vector<int> >&)'
    6 | int dfs (int padre, int nodo, vector<vector<int>>& listaAdy, int pop[], vector<vector<int>>& dp){
      |                                                              ~~~~^~~~~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:20:21: error: request for member 'push_back' in 'listaAdy.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   20 |         listaAdy[a].push_back(b);
      |                     ^~~~~~~~~
traffic.cpp:22:42: error: expected primary-expression before 'N'
   22 |    vector<vector<int>> dp(N, vector<int> N(-1));
      |                                          ^
traffic.cpp:24:33: error: 'n' was not declared in this scope
   24 |    for(int ciudad = 0; ciudad < n; ++ciudad){
      |                                 ^
traffic.cpp:26:39: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   26 |         for(int conex: listaAdy[ciudad]){
      |                                       ^
      |                                       std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from traffic.cpp:2:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
traffic.cpp:26:39: error: 'end' was not declared in this scope; did you mean 'std::end'?
   26 |         for(int conex: listaAdy[ciudad]){
      |                                       ^
      |                                       std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from traffic.cpp:2:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
traffic.cpp:27:47: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'std::vector<int>'
   27 |             act = max(act, dfs(ciudad, conex, listaAdy, pp, dp));
      |                                               ^~~~~~~~
traffic.cpp:6:52: note: in passing argument 3 of 'int dfs(int, int, std::vector<std::vector<int> >&, int*, std::vector<std::vector<int> >&)'
    6 | int dfs (int padre, int nodo, vector<vector<int>>& listaAdy, int pop[], vector<vector<int>>& dp){
      |                               ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~