Language: C++

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX_H = 210;
const int MAX_W = 210;
using State = pair<LL, PII>; // <score, (h, w)>
int H, W;
VVI a;

int dp[MAX_H][MAX_W][MAX_H][MAX_W];

int main(void) {
    scanf("%d%d", &H, &W);
    a.resize(H, VI(W));
    for_each(ALL(a), [](auto &v) {
        for_each(ALL(v), [](int &e){scanf("%d", &e);});
    });
    assert(H <= 30 && W <= 30);
    dp[0][0][0][0] = a[0][0];
    REP(eh, H) REP(ew, W) REP(sh, H) REP(sw, W) {
        if (eh == 0 && ew == 0 && sh == 0 && sw == 0) continue;
        LL buf = 0;
        if (eh && sh) buf = max(buf, dp[eh - 1][ew][sh - 1][sw]);
        if (eh && sw) buf = max(buf, dp[eh - 1][ew][sh][sw - 1]);
        if (ew && sw) buf = max(buf, dp[eh][ew - 1][sh][sw - 1]);
        if (ew && sh) buf = max(buf, dp[eh][ew - 1][sh - 1][sw]);
        if (eh == sh && ew == sw) dp[eh][ew][sh][sw] = buf + a[sh][sw];
        else dp[eh][ew][sh][sw] = buf + a[eh][ew] + a[sh][sw];
    }
    cout << dp[H - 1][W - 1][H - 1][W - 1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:32: error: no matching function for call to 'max(LL&, int&)'
   82 |         if (eh && sh) buf = max(buf, dp[eh - 1][ew][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:82:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   82 |         if (eh && sh) buf = max(buf, dp[eh - 1][ew][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/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:82:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   82 |         if (eh && sh) buf = max(buf, dp[eh - 1][ew][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:83:32: error: no matching function for call to 'max(LL&, int&)'
   83 |         if (eh && sw) buf = max(buf, dp[eh - 1][ew][sh][sw - 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:   template argument deduction/substitution failed:
a.cc:83:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   83 |         if (eh && sw) buf = max(buf, dp[eh - 1][ew][sh][sw - 1]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:83:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   83 |         if (eh && sw) buf = max(buf, dp[eh - 1][ew][sh][sw - 1]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:84:32: error: no matching function for call to 'max(LL&, int&)'
   84 |         if (ew && sw) buf = max(buf, dp[eh][ew - 1][sh][sw - 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:   template argument deduction/substitution failed:
a.cc:84:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   84 |         if (ew && sw) buf = max(buf, dp[eh][ew - 1][sh][sw - 1]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:84:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   84 |         if (ew && sw) buf = max(buf, dp[eh][ew - 1][sh][sw - 1]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:85:32: error: no matching function for call to 'max(LL&, int&)'
   85 |         if (ew && sh) buf = max(buf, dp[eh][ew - 1][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:85:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   85 |         if (ew && sh) buf = max(buf, dp[eh][ew - 1][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:85:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   85 |         if (ew && sh) buf = max(buf, dp[eh][ew - 1][sh - 1][sw]);
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~