Submission #1038604

#TimeUsernameProblemLanguageResultExecution timeMemory
1038604Marco_EscandonCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #include "fish.h" typedef long long ll; #define x first #define y second vector<vector<pair<ll,ll>>> cad; vector<vector<ll>> index; /// @brief costo en la columna i /// @param i columna /// @param j valor del puente /// @return ll cost(ll i, ll j){ ll a=-1,b=cad[i].size(); while(abs(a-b)!=1){ ll m=(a+b)/2; if(cad[i][m].x<=j) a=m; else b=m; } if(b==0) return 0; return cad[i][b-1].y; } /// @brief mayor k tal que index[i][k] <= j /// @param i columna /// @param j valor /// @return posicion ll idx(ll i, ll j){ ll a=-1,b=index[i].size(); while(abs(a-b)!=1){ ll m=(a+b)/2; if(index[i][m]<=j) a=m; else b=m; } return b-1; } long long max_weights(int n, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> w) { cad.resize(n+1); index.resize(n+1); vector<vector<vector<ll>>> dp(n+1); for(int i=0; i<X.size(); i++){ cad[X[i]+1].push_back({Y[i]+1,w[i]}); if(X[i]!=0) index[X[i]].push_back(Y[i]+1); if(X[i]+2<=n) index[X[i]+2].push_back(Y[i]+1); } for(int i=0; i<cad.size(); i++) { index[i].push_back(0); sort(cad[i].begin(),cad[i].end()); sort(index[i].begin(),index[i].end()); dp[i].assign(index[i].size(),{0,0}); for(int j=1; j<cad[i].size(); j++) cad[i][j].y+=cad[i][j-1].y; } ll bs=0; for(int i=1; i<=n; i++) { for(int j=0; j<index[i].size(); j++) { for(int l=idx(i-1,index[i][j])+1; l<dp[i-1].size(); l++)/// 321 & 231 dp[i][j][0]=max(dp[i][j][0],(max(dp[i-1][l][0],dp[i-1][l][1])+cost(i,index[i-1][l]))-cost(i,index[i][j])); for(int l=0; l<=idx(i-1,index[i][j]); l++)/// 123 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i,index[i-1][l]))+cost(i,index[i][j])); if(i>=2) for(int l=0; l<dp[i-2].size(); l++)/// 103 dp[i][j][1]=max(dp[i][j][1],max(dp[i-2][l][1],dp[i-2][l][1])+cost(i-1,max(index[i][j],index[i-2][l])) ); bs=max(bs,max(dp[i][j][0],dp[i][j][1]));// salvar la respuesta } } return bs; }

Compilation message (stderr)

fish.cpp:8:21: error: 'std::vector<std::vector<long long int> > index' redeclared as different kind of entity
    8 | vector<vector<ll>>  index;
      |                     ^~~~~
In file included from /usr/include/string.h:432,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from fish.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
fish.cpp: In function 'll idx(ll, ll)':
fish.cpp:28:20: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   28 |     ll a=-1,b=index[i].size();
      |                    ^
fish.cpp:31:17: error: invalid types '<unresolved overloaded function type>[ll {aka long long int}]' for array subscript
   31 |         if(index[i][m]<=j) a=m;
      |                 ^
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:37:28: error: overloaded function with no contextual type information
   37 |     cad.resize(n+1); index.resize(n+1);
      |                            ^~~~~~
fish.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0; i<X.size(); i++){
      |                  ~^~~~~~~~~
fish.cpp:41:28: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   41 |         if(X[i]!=0)   index[X[i]].push_back(Y[i]+1);
      |                            ^
fish.cpp:42:28: error: invalid types '<unresolved overloaded function type>[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   42 |         if(X[i]+2<=n) index[X[i]+2].push_back(Y[i]+1);
      |                            ^
fish.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=0; i<cad.size(); i++)
      |                  ~^~~~~~~~~~~
fish.cpp:46:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   46 |         index[i].push_back(0);
      |              ^
fish.cpp:48:19: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   48 |         sort(index[i].begin(),index[i].end());
      |                   ^
fish.cpp:48:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   48 |         sort(index[i].begin(),index[i].end());
      |                                    ^
fish.cpp:49:27: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   49 |         dp[i].assign(index[i].size(),{0,0});
      |                           ^
fish.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int j=1; j<cad[i].size(); j++)
      |                      ~^~~~~~~~~~~~~~
fish.cpp:57:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   57 |         for(int j=0; j<index[i].size(); j++)
      |                             ^
fish.cpp:59:36: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   59 |             for(int l=idx(i-1,index[i][j])+1; l<dp[i-1].size(); l++)///                                              321 & 231
      |                                    ^
fish.cpp:59:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |             for(int l=idx(i-1,index[i][j])+1; l<dp[i-1].size(); l++)///                                              321 & 231
      |                                               ~^~~~~~~~~~~~~~~
fish.cpp:60:91: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |                 dp[i][j][0]=max(dp[i][j][0],(max(dp[i-1][l][0],dp[i-1][l][1])+cost(i,index[i-1][l]))-cost(i,index[i][j]));
      |                                                                                           ^
fish.cpp:60:114: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   60 |                 dp[i][j][0]=max(dp[i][j][0],(max(dp[i-1][l][0],dp[i-1][l][1])+cost(i,index[i-1][l]))-cost(i,index[i][j]));
      |                                                                                                                  ^
fish.cpp:62:42: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   62 |             for(int l=0; l<=idx(i-1,index[i][j]); l++)///                                                            123
      |                                          ^
fish.cpp:63:72: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   63 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i,index[i-1][l]))+cost(i,index[i][j]));
      |                                                                        ^
fish.cpp:63:95: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   63 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i,index[i-1][l]))+cost(i,index[i][j]));
      |                                                                                               ^
fish.cpp:65:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             for(int l=0; l<dp[i-2].size(); l++)///                                                            103
      |                          ~^~~~~~~~~~~~~~~
fish.cpp:66:96: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],max(dp[i-2][l][1],dp[i-2][l][1])+cost(i-1,max(index[i][j],index[i-2][l])) );
      |                                                                                                ^
fish.cpp:66:108: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],max(dp[i-2][l][1],dp[i-2][l][1])+cost(i-1,max(index[i][j],index[i-2][l])) );
      |                                                                                                            ^