답안 #629819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
629819 2022-08-15T08:14:12 Z Vovamatrix 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
//https://oj.uz/problem/view/IOI22_fish
#include "fish.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
 
#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define ima_li_te(D,d)  find(all(D),d)
#define MAXN 100007
#define MAXM 300007
ll dp[2][3][MAXN];
ll sol(int n, int m, vector<int> x, vector<int> y, vector<int> w)
{
    vector<int,ll> v[n];
    ll cnt=0;
    for(int i=0;i<m;i++) y[i]++;
    for(int i=0;i<m;i++) v[x[i]].pb(mp(y[i],w[i]));
    for(int i=0;i<n;i++)
    {
        v[i].pb(mp(0,0)); sort(all(v[i])); v[i].pb(mp(n+2,0));
        for(int j=1;j<v[i].size();j++) v[i][j].sc+=v[i][j-1].sc;
    }
    for(int i=0;i<v[1].size();i++)
    {
        ll k=0;
        while(k+1<v[0].size() && v[1][i].fi>v[0][k+1].fi) k++;
        dp[1][2][i]=v[1].back().sc-v[1][max(i-1,0)].sc;
        dp[1][1][i]=v[0][k].sc;
    }
    for(int i=0;i<v[0].size();i++)
    {
        ll k=0;
        while(k+1<v[1].size() && v[0][i].fi>v[1][k+1].fi) k++;
        dp[1][0][i]=v[1][k].sc;
    }
    for(int i=2;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            for(int k=0;k<max(v[i-1].size(),v[i].size());k++) dp[i&1][j][k]=0;
        }
        for(int j=0;j<v[i-1].size();j++)
        {
            ll k=0;
            while(k+1<v[i].size() && v[i-1][j].fi>v[i][k+1].fi) k++;
            dp[i&1][0][j]=max(dp[(i&1)^1][1][j],dp[(i&1)^1][2][j])+v[i][k].sc;
        }
        cnt=-1;
        for(int j=0;j<v[i].size();j++)
        {
            ll k=0,l=0,p=0;
            while(k<v[i-2].size() && v[i][j].fi>v[i-2][k].fi)
            {
                while(l<v[i-1].size()-1 && v[i-2][k].fi>v[i-1][l+1].fi) l++;
                cnt=max(cnt,dp[(i&1)^1][0][k]+v[i-1][l].sc);
                k++;
            }
            while(p<v[i-1].size()-1 && v[i][j].fi>v[i-1][p+1].fi) p++;
            dp[i&1][1][j]=max(dp[i&1][1][j],cnt-v[i-1][p].sc);
        }
        cnt=-1;
        for(int j=v[i].size()-1;j>=0;j--)
        {
            ll k=v[i-2].size()-1;
            while(k>=0 && v[i][j].fi<=v[i-2][k].fi)
            {
                cnt=max(cnt,dp[(i&1)^1][0][k]);
                k--;
            }
            dp[i&1][1][j]=max(dp[i&1][1][j],cnt);
        }
        cnt=-1;
        for(int j=0;j<v[i].size();j++)
        {
            ll k=0,l=0;
            while(k<v[i-1].size() && v[i][j].fi>=v[i-1][k].fi)
            {
                cnt=max(cnt, dp[(i&1)^1][1][k]-v[i-1][max(k-1,0ll)].sc);
                k++;
            }
            while(l<v[i-1].size()-1 && v[i][j].fi > v[i-1][l].fi) l++;
            dp[i&1][1][j]=max(dp[i&1][1][j],cnt+v[i-1][max(l-1,0ll)].sc);
        }
        cnt=-1;
        for(int j=v[i].size()-1;j>=0;j--)
        {
            ll k=v[i-1].size()-1,l=v[i].size()-1;
            while(k>=0 && v[i][j].fi<v[i-1][k].fi)
            {
                while(l>0 && v[i-1][k].fi<=v[i][l].fi) l--;
                cnt=max(cnt,max(dp[(i&1)^1][1][k],dp[(i&1)^1][2][k])+v[i][l].sc);
                k--;
            }
            dp[i&1][2][j]=max(dp[i&1][2][j],cnt-v[i][max(j-1,0)].sc);
        }
    }
    ll rez=0;
    for(int i=0;i<v[n-2].size();i++) rez=max(rez,dp[(n-1)&1][0][i]);
    for(int i=1;i<3;i++)
    {
        for(int j=0;j<v[n-1].size();j++) rez=max(rez,dp[(n-1)&1][i][j]);
    }
    return rez;
}

Compilation message

In file included from /usr/include/c++/10/vector:67,
                 from fish.h:1,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<int, long long int>':
/usr/include/c++/10/bits/stl_vector.h:389:11:   required from 'class std::vector<int, long long int>'
fish.cpp:30:23:   required from here
/usr/include/c++/10/bits/stl_vector.h:87:21: error: 'long long int' is not a class, struct, or union type
   87 |  rebind<_Tp>::other _Tp_alloc_type;
      |                     ^~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:89:9: error: 'long long int' is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/10/bits/stl_vector.h: In instantiation of 'class std::vector<int, long long int>':
fish.cpp:30:23:   required from here
/usr/include/c++/10/bits/stl_vector.h:404:64: error: 'long long int' is not a class, struct, or union type
  404 |       static_assert(is_same<typename _Alloc::value_type, _Tp>::value,
      |                                                                ^~~~~
/usr/include/c++/10/bits/stl_vector.h:474:20: error: '_M_allocate' has not been declared in 'std::_Base<int, long long int>'
  474 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:475:20: error: '_M_deallocate' has not been declared in 'std::_Base<int, long long int>'
  475 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:477:20: error: '_M_get_Tp_allocator' has not been declared in 'std::_Base<int, long long int>'
  477 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:59,
                 from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::_Vector_impl::_Vector_impl() [with _Tp = int; _Alloc = long long int]':
fish.cpp:30:23:   recursively required from 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = long long int]'
fish.cpp:30:23:   required from here
/usr/include/c++/10/bits/stl_vector.h:131:17: error: 'long long int' is not a class, struct, or union type
  131 |  _Vector_impl() _GLIBCXX_NOEXCEPT_IF(
      |                 ^~~~~~~~~~~~~~~~~~~~
fish.cpp: In function 'long long int sol(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:33:50: error: no matching function for call to 'std::vector<int, long long int>::push_back(std::pair<int, int>)'
   33 |     for(int i=0;i<m;i++) v[x[i]].pb(mp(y[i],w[i]));
      |                                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from fish.h:1,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int, long long int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
fish.cpp:36:24: error: no matching function for call to 'std::vector<int, long long int>::push_back(std::pair<int, int>)'
   36 |         v[i].pb(mp(0,0)); sort(all(v[i])); v[i].pb(mp(n+2,0));
      |                        ^
In file included from /usr/include/c++/10/vector:67,
                 from fish.h:1,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int, long long int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
fish.cpp:21:30: error: 'class std::vector<int, long long int>' has no member named 'begin'
   21 | #define all(data)       data.begin(),data.end()
      |                              ^~~~~
fish.cpp:36:32: note: in expansion of macro 'all'
   36 |         v[i].pb(mp(0,0)); sort(all(v[i])); v[i].pb(mp(n+2,0));
      |                                ^~~
fish.cpp:21:43: error: 'class std::vector<int, long long int>' has no member named 'end'
   21 | #define all(data)       data.begin(),data.end()
      |                                           ^~~
fish.cpp:36:32: note: in expansion of macro 'all'
   36 |         v[i].pb(mp(0,0)); sort(all(v[i])); v[i].pb(mp(n+2,0));
      |                                ^~~
fish.cpp:36:61: error: no matching function for call to 'std::vector<int, long long int>::push_back(std::pair<int, int>)'
   36 |         v[i].pb(mp(0,0)); sort(all(v[i])); v[i].pb(mp(n+2,0));
      |                                                             ^
In file included from /usr/include/c++/10/vector:67,
                 from fish.h:1,
                 from fish.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = long long int; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int, long long int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
fish.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j=1;j<v[i].size();j++) v[i][j].sc+=v[i][j-1].sc;
      |                     ~^~~~~~~~~~~~
fish.cpp:37:44: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   37 |         for(int j=1;j<v[i].size();j++) v[i][j].sc+=v[i][j-1].sc;
      |                                            ^
fish.cpp:37:56: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   37 |         for(int j=1;j<v[i].size();j++) v[i][j].sc+=v[i][j-1].sc;
      |                                                        ^
fish.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<v[1].size();i++)
      |                 ~^~~~~~~~~~~~
fish.cpp:42:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while(k+1<v[0].size() && v[1][i].fi>v[0][k+1].fi) k++;
      |               ~~~^~~~~~~~~~~~
fish.cpp:42:38: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   42 |         while(k+1<v[0].size() && v[1][i].fi>v[0][k+1].fi) k++;
      |                                      ^
fish.cpp:42:49: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   42 |         while(k+1<v[0].size() && v[1][i].fi>v[0][k+1].fi) k++;
      |                                                 ^
fish.cpp:43:26: error: 'class std::vector<int, long long int>' has no member named 'back'
   43 |         dp[1][2][i]=v[1].back().sc-v[1][max(i-1,0)].sc;
      |                          ^~~~
fish.cpp:43:40: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'const int')
   43 |         dp[1][2][i]=v[1].back().sc-v[1][max(i-1,0)].sc;
      |                                        ^
fish.cpp:44:25: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   44 |         dp[1][1][i]=v[0][k].sc;
      |                         ^
fish.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0;i<v[0].size();i++)
      |                 ~^~~~~~~~~~~~
fish.cpp:49:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         while(k+1<v[1].size() && v[0][i].fi>v[1][k+1].fi) k++;
      |               ~~~^~~~~~~~~~~~
fish.cpp:49:38: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   49 |         while(k+1<v[1].size() && v[0][i].fi>v[1][k+1].fi) k++;
      |                                      ^
fish.cpp:49:49: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   49 |         while(k+1<v[1].size() && v[0][i].fi>v[1][k+1].fi) k++;
      |                                                 ^
fish.cpp:50:25: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   50 |         dp[1][0][i]=v[1][k].sc;
      |                         ^
fish.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   56 |             for(int k=0;k<max(v[i-1].size(),v[i].size());k++) dp[i&1][j][k]=0;
      |                         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         for(int j=0;j<v[i-1].size();j++)
      |                     ~^~~~~~~~~~~~~~
fish.cpp:61:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             while(k+1<v[i].size() && v[i-1][j].fi>v[i][k+1].fi) k++;
      |                   ~~~^~~~~~~~~~~~
fish.cpp:61:44: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   61 |             while(k+1<v[i].size() && v[i-1][j].fi>v[i][k+1].fi) k++;
      |                                            ^
fish.cpp:61:55: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   61 |             while(k+1<v[i].size() && v[i-1][j].fi>v[i][k+1].fi) k++;
      |                                                       ^
fish.cpp:62:72: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   62 |             dp[i&1][0][j]=max(dp[(i&1)^1][1][j],dp[(i&1)^1][2][j])+v[i][k].sc;
      |                                                                        ^
fish.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int j=0;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~
fish.cpp:68:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |             while(k<v[i-2].size() && v[i][j].fi>v[i-2][k].fi)
      |                   ~^~~~~~~~~~~~~~
fish.cpp:68:42: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   68 |             while(k<v[i-2].size() && v[i][j].fi>v[i-2][k].fi)
      |                                          ^
fish.cpp:68:55: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   68 |             while(k<v[i-2].size() && v[i][j].fi>v[i-2][k].fi)
      |                                                       ^
fish.cpp:70:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                 while(l<v[i-1].size()-1 && v[i-2][k].fi>v[i-1][l+1].fi) l++;
      |                       ~^~~~~~~~~~~~~~~~
fish.cpp:70:50: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   70 |                 while(l<v[i-1].size()-1 && v[i-2][k].fi>v[i-1][l+1].fi) l++;
      |                                                  ^
fish.cpp:70:63: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   70 |                 while(l<v[i-1].size()-1 && v[i-2][k].fi>v[i-1][l+1].fi) l++;
      |                                                               ^
fish.cpp:71:53: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   71 |                 cnt=max(cnt,dp[(i&1)^1][0][k]+v[i-1][l].sc);
      |                                                     ^
fish.cpp:74:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |             while(p<v[i-1].size()-1 && v[i][j].fi>v[i-1][p+1].fi) p++;
      |                   ~^~~~~~~~~~~~~~~~
fish.cpp:74:44: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   74 |             while(p<v[i-1].size()-1 && v[i][j].fi>v[i-1][p+1].fi) p++;
      |                                            ^
fish.cpp:74:57: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   74 |             while(p<v[i-1].size()-1 && v[i][j].fi>v[i-1][p+1].fi) p++;
      |                                                         ^
fish.cpp:75:55: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   75 |             dp[i&1][1][j]=max(dp[i&1][1][j],cnt-v[i-1][p].sc);
      |                                                       ^
fish.cpp:81:31: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   81 |             while(k>=0 && v[i][j].fi<=v[i-2][k].fi)
      |                               ^
fish.cpp:81:45: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   81 |             while(k>=0 && v[i][j].fi<=v[i-2][k].fi)
      |                                             ^
fish.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   89 |         for(int j=0;j<v[i].size();j++)
      |                     ~^~~~~~~~~~~~
fish.cpp:92:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int, long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   92 |             while(k<v[i-1].size() && v[i][j].fi>=v[i-1][k].fi)
      |                   ~^~~~~~~~~~~~~~
fish.cpp:92:42: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'int')
   92 |             while(k<v[i-1].size() && v[i][j].fi>=v[i-1][k].fi)
      |                                          ^
fish.cpp:92:56: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'long long int')
   92 |             while(k<v[i-1].size() && v[i][j].fi>=v[i-1][k].fi)
      |                                                        ^
fish.cpp:94:54: error: no match for 'operator[]' (operand types are 'std::vector<int, long long int>' and 'const long long int')
   94 |                 cnt=max(cnt, dp[(i&1)^1][1][k]-v[i-1][