Submission #553973

#TimeUsernameProblemLanguageResultExecution timeMemory
553973a_aguiloTraffic (IOI10_traffic)C++14
Compilation error
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, pop, 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; }

Compilation message (stderr)

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){
      |                               ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~