제출 #1039153

#제출 시각아이디문제언어결과실행 시간메모리
1039153Marco_Escandon메기 농장 (IOI22_fish)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; include "fish.h" typedef long long ll; #pragma optimize("O3") #define x first #define y second vector<vector<pair<ll,ll>>> cad; vector<vector<ll>> indice; /// @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 indice[i][k] <= j /// @param i columna /// @param j valor /// @return posicion ll idx(ll i, ll j){ ll a=-1,b=indice[i].size(); while(abs(a-b)!=1){ ll m=(a+b)/2; if(indice[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); indice.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) indice[X[i]].push_back(Y[i]+1); if(X[i]+2<=n) indice[X[i]+2].push_back(Y[i]+1); } for(int i=0; i<cad.size(); i++) { indice[i].push_back(0); sort(cad[i].begin(),cad[i].end()); sort(indice[i].begin(),indice[i].end()); dp[i].assign(indice[i].size(),{0,0}); for(int j=1; j<cad[i].size(); j++) cad[i][j].y+=cad[i][j-1].y; } vector<vector<vector<ll>>> dpac=dp; ll bs=0; for(int i=1; i<=n; i++) { for(int j=0; j<indice[i].size(); j++) { ll idxtemp=idx(i-1,indice[i][j]); ll costoij=cost(i,indice[i][j]); ll costoi_1j=cost(i-1,indice[i][j]); if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij); for(int l=0; l<=idxtemp; l++) dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j); if(i>=2) { for(int l=0; l<dp[i-2].size(); l++) { dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l])); dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+costoi_1j); } } dpac[i][j][0]=max(dp[i][j][0],dp[i][j][1]); if(i<n) dpac[i][j][0]+=cost(i+1,indice[i][j]); dpac[i][j][1]=max(dp[i][j][0],dp[i][j][1]); bs=max(bs,max(dp[i][j][0],dp[i][j][1]));// salvar la respuesta } for(int j=indice[i].size()-2; j>-1; j--) dpac[i][j][0]=max(dpac[i][j][0],dpac[i][j+1][0]); } return bs; }

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

fish.cpp:5: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    5 | #pragma optimize("O3")
      | 
fish.cpp:3:1: error: 'include' does not name a type
    3 | include "fish.h"
      | ^~~~~~~
fish.cpp:8:20: error: 'll' was not declared in this scope
    8 | vector<vector<pair<ll,ll>>>  cad;
      |                    ^~
fish.cpp:8:23: error: 'll' was not declared in this scope
    8 | vector<vector<pair<ll,ll>>>  cad;
      |                       ^~
fish.cpp:8:23: error: template argument 1 is invalid
fish.cpp:8:23: error: template argument 2 is invalid
fish.cpp:8:25: error: template argument 1 is invalid
    8 | vector<vector<pair<ll,ll>>>  cad;
      |                         ^~
fish.cpp:8:25: error: template argument 2 is invalid
fish.cpp:8:27: error: template argument 1 is invalid
    8 | vector<vector<pair<ll,ll>>>  cad;
      |                           ^
fish.cpp:8:27: error: template argument 2 is invalid
fish.cpp:9:15: error: 'll' was not declared in this scope
    9 | vector<vector<ll>>  indice;
      |               ^~
fish.cpp:9:15: error: template argument 1 is invalid
fish.cpp:9:15: error: template argument 2 is invalid
fish.cpp:9:17: error: template argument 1 is invalid
    9 | vector<vector<ll>>  indice;
      |                 ^~
fish.cpp:9:17: error: template argument 2 is invalid
fish.cpp:14:1: error: 'll' does not name a type
   14 | ll cost(ll i, ll j){
      | ^~
fish.cpp:28:1: error: 'll' does not name a type
   28 | ll idx(ll i, ll j){
      | ^~
fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:38:9: error: request for member 'resize' in 'cad', which is of non-class type 'int'
   38 |     cad.resize(n+1); indice.resize(n+1);
      |         ^~~~~~
fish.cpp:38:29: error: request for member 'resize' in 'indice', which is of non-class type 'int'
   38 |     cad.resize(n+1); indice.resize(n+1);
      |                             ^~~~~~
fish.cpp:39:26: error: 'll' was not declared in this scope
   39 |     vector<vector<vector<ll>>>  dp(n+1);
      |                          ^~
fish.cpp:39:26: error: template argument 1 is invalid
fish.cpp:39:26: error: template argument 2 is invalid
fish.cpp:39:28: error: template argument 1 is invalid
   39 |     vector<vector<vector<ll>>>  dp(n+1);
      |                            ^~
fish.cpp:39:28: error: template argument 2 is invalid
fish.cpp:39:30: error: template argument 1 is invalid
   39 |     vector<vector<vector<ll>>>  dp(n+1);
      |                              ^
fish.cpp:39:30: error: template argument 2 is invalid
fish.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i=0; i<X.size(); i++){
      |                  ~^~~~~~~~~
fish.cpp:41:12: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   41 |         cad[X[i]+1].push_back({Y[i]+1,w[i]});
      |            ^
fish.cpp:42:29: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   42 |         if(X[i]!=0)   indice[X[i]].push_back(Y[i]+1);
      |                             ^
fish.cpp:43:29: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   43 |         if(X[i]+2<=n) indice[X[i]+2].push_back(Y[i]+1);
      |                             ^
fish.cpp:45:24: error: request for member 'size' in 'cad', which is of non-class type 'int'
   45 |     for(int i=0; i<cad.size(); i++)
      |                        ^~~~
fish.cpp:47:15: error: invalid types 'int[int]' for array subscript
   47 |         indice[i].push_back(0);
      |               ^
fish.cpp:48:17: error: invalid types 'int[int]' for array subscript
   48 |         sort(cad[i].begin(),cad[i].end());
      |                 ^
fish.cpp:48:32: error: invalid types 'int[int]' for array subscript
   48 |         sort(cad[i].begin(),cad[i].end());
      |                                ^
fish.cpp:49:20: error: invalid types 'int[int]' for array subscript
   49 |         sort(indice[i].begin(),indice[i].end());
      |                    ^
fish.cpp:49:38: error: invalid types 'int[int]' for array subscript
   49 |         sort(indice[i].begin(),indice[i].end());
      |                                      ^
fish.cpp:50:11: error: invalid types 'int[int]' for array subscript
   50 |         dp[i].assign(indice[i].size(),{0,0});
      |           ^
fish.cpp:50:28: error: invalid types 'int[int]' for array subscript
   50 |         dp[i].assign(indice[i].size(),{0,0});
      |                            ^
fish.cpp:51:27: error: invalid types 'int[int]' for array subscript
   51 |         for(int j=1; j<cad[i].size(); j++)
      |                           ^
fish.cpp:52:16: error: invalid types 'int[int]' for array subscript
   52 |             cad[i][j].y+=cad[i][j-1].y;
      |                ^
fish.cpp:52:29: error: invalid types 'int[int]' for array subscript
   52 |             cad[i][j].y+=cad[i][j-1].y;
      |                             ^
fish.cpp:54:26: error: template argument 2 is invalid
   54 |     vector<vector<vector<ll>>>  dpac=dp;
      |                          ^~
fish.cpp:54:28: error: template argument 1 is invalid
   54 |     vector<vector<vector<ll>>>  dpac=dp;
      |                            ^~
fish.cpp:54:28: error: template argument 2 is invalid
fish.cpp:54:30: error: template argument 1 is invalid
   54 |     vector<vector<vector<ll>>>  dpac=dp;
      |                              ^
fish.cpp:54:30: error: template argument 2 is invalid
fish.cpp:55:7: error: expected ';' before 'bs'
   55 |     ll bs=0;
      |       ^~~
      |       ;
fish.cpp:58:30: error: invalid types 'int[int]' for array subscript
   58 |         for(int j=0; j<indice[i].size(); j++)
      |                              ^
fish.cpp:60:15: error: expected ';' before 'idxtemp'
   60 |             ll idxtemp=idx(i-1,indice[i][j]);
      |               ^~~~~~~~
      |               ;
fish.cpp:61:15: error: expected ';' before 'costoij'
   61 |             ll costoij=cost(i,indice[i][j]);
      |               ^~~~~~~~
      |               ;
fish.cpp:62:15: error: expected ';' before 'costoi_1j'
   62 |             ll costoi_1j=cost(i-1,indice[i][j]);
      |               ^~~~~~~~~~
      |               ;
fish.cpp:63:16: error: 'idxtemp' was not declared in this scope
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                ^~~~~~~
fish.cpp:63:30: error: invalid types 'int[int]' for array subscript
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                              ^
fish.cpp:63:46: error: invalid types 'int[int]' for array subscript
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                                              ^
fish.cpp:63:62: error: invalid types 'int[int]' for array subscript
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                                                              ^
fish.cpp:63:76: error: invalid types 'int[int]' for array subscript
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                                                                            ^
fish.cpp:63:96: error: 'costoij' was not declared in this scope
   63 |             if(idxtemp+1<dpac[i-1].size()) dp[i][j][0]=max(dp[i][j][0],dpac[i-1][idxtemp+1][0]-costoij);
      |                                                                                                ^~~~~~~
fish.cpp:65:29: error: 'idxtemp' was not declared in this scope
   65 |             for(int l=0; l<=idxtemp; l++)
      |                             ^~~~~~~
fish.cpp:66:19: error: invalid types 'int[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                   ^
fish.cpp:66:35: error: invalid types 'int[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                                   ^
fish.cpp:66:48: error: invalid types 'int[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                                                ^
fish.cpp:66:75: error: invalid types 'int[int]' for array subscript
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                                                                           ^
fish.cpp:66:60: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                                                            ^~~~
      |                                                            cosl
fish.cpp:66:86: error: 'costoi_1j' was not declared in this scope
   66 |                 dp[i][j][1]=max(dp[i][j][1],(dp[i-1][l][1]-cost(i-1,indice[i-1][l]))+costoi_1j);
      |                                                                                      ^~~~~~~~~
fish.cpp:70:34: error: invalid types 'int[int]' for array subscript
   70 |                 for(int l=0; l<dp[i-2].size(); l++)
      |                                  ^
fish.cpp:72:23: error: invalid types 'int[int]' for array subscript
   72 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l]));
      |                       ^
fish.cpp:72:39: error: invalid types 'int[int]' for array subscript
   72 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l]));
      |                                       ^
fish.cpp:72:53: error: invalid types 'int[int]' for array subscript
   72 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l]));
      |                                                     ^
fish.cpp:72:80: error: invalid types 'int[int]' for array subscript
   72 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l]));
      |                                                                                ^
fish.cpp:72:65: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   72 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+cost(i-1,indice[i-2][l]));
      |                                                                 ^~~~
      |                                                                 cosl
fish.cpp:73:23: error: invalid types 'int[int]' for array subscript
   73 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+costoi_1j);
      |                       ^
fish.cpp:73:39: error: invalid types 'int[int]' for array subscript
   73 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+costoi_1j);
      |                                       ^
fish.cpp:73:53: error: invalid types 'int[int]' for array subscript
   73 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+costoi_1j);
      |                                                     ^
fish.cpp:73:65: error: 'costoi_1j' was not declared in this scope
   73 |                     dp[i][j][1]=max(dp[i][j][1],dpac[i-2][l][1]+costoi_1j);
      |                                                                 ^~~~~~~~~
fish.cpp:78:17: error: invalid types 'int[int]' for array subscript
   78 |             dpac[i][j][0]=max(dp[i][j][0],dp[i][j][1]);
      |                 ^
fish.cpp:78:33: error: invalid types 'int[int]' for array subscript
   78 |             dpac[i][j][0]=max(dp[i][j][0],dp[i][j][1]);
      |                                 ^
fish.cpp:78:45: error: invalid types 'int[int]' for array subscript
   78 |             dpac[i][j][0]=max(dp[i][j][0],dp[i][j][1]);
      |                                             ^
fish.cpp:79:25: error: invalid types 'int[int]' for array subscript
   79 |             if(i<n) dpac[i][j][0]+=cost(i+1,indice[i][j]);
      |                         ^
fish.cpp:79:51: error: invalid types 'int[int]' for array subscript
   79 |             if(i<n) dpac[i][j][0]+=cost(i+1,indice[i][j]);
      |                                                   ^
fish.cpp:79:36: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   79 |             if(i<n) dpac[i][j][0]+=cost(i+1,indice[i][j]);
      |                                    ^~~~
      |                                    cosl
fish.cpp:81:17: error: invalid types 'int[int]' for array subscript
   81 |             dpac[i][j][1]=max(dp[i][j][0],dp[i][j][1]);
      |                 ^
fish.cpp:81:33: error: invalid types 'int[int]' for array subscript
   81 |             dpac[i][j][1]=max(dp[i][j][0],dp[i][j][1]);
      |                                 ^
fish.cpp:81:45: error: invalid types 'int[int]' for array subscript
   81 |             dpac[i][j][1]=max(dp[i][j][0],dp[i][j][1]);
      |                                             ^
fish.cpp:83:13: error: 'bs' was not declared in this scope; did you mean 'abs'?
   83 |             bs=max(bs,max(dp[i][j][0],dp[i][j][1]));// salvar la respuesta
      |             ^~
      |             abs
fish.cpp:83:29: error: invalid types 'int[int]' for array subscript
   83 |             bs=max(bs,max(dp[i][j][0],dp[i][j][1]));// salvar la respuesta
      |                             ^
fish.cpp:83:41: error: invalid types 'int[int]' for array subscript
   83 |             bs=max(bs,max(dp[i][j][0],dp[i][j][1]));// salvar la respuesta
      |                                         ^
fish.cpp:85:25: error: invalid types 'int[int]' for array subscript
   85 |         for(int j=indice[i].size()-2; j>-1; j--)
      |                         ^
fish.cpp:86:17: error: invalid types 'int[int]' for array subscript
   86 |             dpac[i][j][0]=max(dpac[i][j][0],dpac[i][j+1][0]);
      |                 ^
fish.cpp:86:35: error: invalid types 'int[int]' for array subscript
   86 |             dpac[i][j][0]=max(dpac[i][j][0],dpac[i][j+1][0]);
      |                                   ^
fish.cpp:86:49: error: invalid types 'int[int]' for array subscript
   86 |             dpac[i][j][0]=max(dpac[i][j][0],dpac[i][j+1][0]);
      |                                                 ^
fish.cpp:88:12: error: 'bs' was not declared in this scope; did you mean 'abs'?
   88 |     return bs;
      |            ^~
      |            abs