Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <cstdint>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace std;

static long dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:40: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   49 |         rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
      |                                     ~~~^~~~~~~~~~~~~~~~~~~
   50 |             dp[i][j][k][0],
      |             ~~~~~~~~~~~~~~~             
   51 |             dp[i][j][k][1],
      |             ~~~~~~~~~~~~~~~             
   52 |             dp[i][j][k][2],
      |             ~~~~~~~~~~~~~~~             
   53 |             dp[i][j][k][3],
      |             ~~~~~~~~~~~~~~~             
   54 |             dp[i][j][k-1][0]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |             dp[i][j][k-1][1]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |             dp[i][j][k-1][2]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   57 |             dp[i][j][k-1][3]+te[i+1][j]});
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:49:40: note:   deduced conflicting types for parameter '_Tp' ('long int' and 'long long int')
   49 |         rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
      |                                     ~~~^~~~~~~~~~~~~~~~~~~
   50 |             dp[i][j][k][0],
      |             ~~~~~~~~~~~~~~~             
   51 |             dp[i][j][k][1],
      |             ~~~~~~~~~~~~~~~             
   52 |             dp[i][j][k][2],
      |             ~~~~~~~~~~~~~~~             
   53 |             dp[i][j][k][3],
      |             ~~~~~~~~~~~~~~~             
   54 |             dp[i][j][k-1][0]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |             dp[i][j][k-1][1]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |             dp[i][j][k-1][2]+te[i+1][j],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   57 |             dp[i][j][k-1][3]+te[i+1][j]});
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
a.cc:63:40: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   63 |         rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
      |                                     ~~~^~~~~~~~~~~~~~~~~~~
   64 |             dp[i][j][0][k],
      |             ~~~~~~~~~~~~~~~             
   65 |             dp[i][j][1][k],
      |             ~~~~~~~~~~~~~~~             
   66 |             dp[i][j][2][k],
      |             ~~~~~~~~~~~~~~~             
   67 |             dp[i][j][3][k],
      |             ~~~~~~~~~~~~~~~             
   68 |             dp[i][j][0][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |             dp[i][j][1][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |             dp[i][j][2][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 |             dp[i][j][3][k-1]+te[i][j+1]});
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:63:40: note:   deduced conflicting types for parameter '_Tp' ('long int' and 'long long int')
   63 |         rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
      |                                     ~~~^~~~~~~~~~~~~~~~~~~
   64 |             dp[i][j][0][k],
      |             ~~~~~~~~~~~~~~~             
   65 |             dp[i][j][1][k],
      |             ~~~~~~~~~~~~~~~             
   66 |             dp[i][j][2][k],
      |             ~~~~~~~~~~~~~~~             
   67 |             dp[i][j][3][k],
      |             ~~~~~~~~~~~~~~~             
   68 |             dp[i][j][0][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 |             dp[i][j][1][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   70 |             dp[i][j][2][k-1]+te[i][j+1],
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 |             dp[i][j][3][k-1]+te[i][j+1]});
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided
a.cc:75:18: error: no matching function for call to 'max(ll&, long int&)'
   75 |         Maxim=max(Maxim, dp[C-1][R-1][i][j]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:75:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   75 |         Maxim=max(Maxim, dp[C-1][R-1][i][j]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:75:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   75 |         Maxim=max(Maxim, dp[C-1][R-1][i][j]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~