Submission #402969

# Submission time Handle Problem Language Result Execution time Memory
402969 2021-05-12T15:41:13 Z Fidisk Visiting Singapore (NOI20_visitingsingapore) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 1e15
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
typedef pair<pair<long long,long long>,pair<long long,long long>> pllll;
typedef pair<pair<long long,long long>,bool> pllb;

const ll base=361;
const ll mod=998244353;
const ld eps=1e-5;
const ll maxn=1e6;

int k,n,m,a,b,f[5009][5009][2][2],i,j,s[5009],t[5009],v[5009],res;

int main(){
    IO;
    cin>>k>>n>>m>>a>>b;
    for (i=1;i<=k;i++) {
        cin>>v[i];
    }
    for (i=1;i<=n;i++) {
        cin>>s[i];
    }
    for (i=1;i<=m;i++) {
        cin>>t[i];
    }
    for (i=0;i<=n;i++) {
        for (j=0;j<=m;j++) {
            f[i][j][0][0]=-1e9;
            f[i][j][0][1]=-1e9;
            f[i][j][1][0]=-1e9;
        }
    }
    for (i=0;i<=n;i++) {
        f[i][0][0][0]=0;
        for (j=1;j<=m;j++) {
            f[i][j][0][1]=a+j*b;
        }
    }
    res=-1e9;
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
            f[i][j][0][1]=max({f[i][j-1][1][0]+a,f[i][j-1][0][0]+a,f[i][j-1][0][1]})+b;
            if (s[i]==t[j]) {
                f[i][j][1][0]=max({f[i-1][j-1][0][0],f[i-1][j-1][0][1],f[i-1][j-1][1][0]})+v[s[i]];
            }
        }
    }
    for (i=1;i<=n;i++) {
        res=max({res,f[i][m][0][0],f[i][m][1][0],f[i][m][0][1]});
    }
    /*
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            cout<<f[i][j][0][0]<<' ';
        }
        cout<<'\n';
    }
    cout<<'\n';
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            cout<<f[i][j][0][1]<<' ';
        }
        cout<<'\n';
    }
    cout<<'\n';
    for (i=1;i<=n;i++) {
        for (j=1;j<=m;j++) {
            cout<<f[i][j][1][0]<<' ';
        }
        cout<<'\n';
    }
    */
    cout<<res<<'\n';
}

Compilation message

VisitingSingapore.cpp: In function 'int main()':
VisitingSingapore.cpp:58:81: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   58 |             f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
      |                                                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:58:81: note:   candidate expects 2 arguments, 1 provided
   58 |             f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
      |                                                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:58:81: note:   candidate expects 3 arguments, 1 provided
   58 |             f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
      |                                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:58:81: note:   deduced conflicting types for parameter '_Tp' ('int*' and 'int')
   58 |             f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
      |                                                                                 ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:58:81: note:   deduced conflicting types for parameter '_Tp' ('int*' and 'int')
   58 |             f[i][j][0][0]=max({f[i-1][0][1]+a,f[i-1][j][0][0],f[i-1][j][1][0]+a})+b;
      |                                                                                 ^