Language: C++

// sandeep_007  
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define PI acos(-1)
#define mod 1000000007
#define ll long long
#define nitro std::ios_base::sync_with_stdio (false); cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define vi vector < ll >
#define mod 1000000007

bool sortbysec(const pair<ll,ll> &A,
              const pair<ll,ll> &b){
    return (A.second < b.second);
}
 
inline ll mx(ll A,ll b){
    if(A > b) return A;
    else return b;      
}

ll power(ll x,ll y,ll p){
    ll res = 1;   
    x = x % p;    
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; 
        x = (x*x) % p; 
    }
    return res;
}

ll gcd(ll A,ll b){if(b==0) return A; else return gcd(b,A%b);}

#define N 105
#define X(x,u,v) (b[x][v]-b[x][(u)-1])
#define Y(x,u,v) (a[v][x]-a[(u)-1][x])
int n,m,u,v;short dp[N][N][N][N],a[N][N],b[N][N],Ans;

int main()
{
    #ifdef DBG
        freopen("in","r",stdin);
    #endif

    // scanf("%d%d",&n,&m);
    cin >> n >> m;
    for (int i=1;i<=n;i++){
        // scanf("%s",s+1);
        string s;
        cin >> s;
        for (int j=1;j<=m;j++)
        {
            if (s[j]=='E') u=i,v=j;
            if (s[j]=='o') a[i][j]=b[i][j]=1;
            a[i][j]+=a[i-1][j];
            b[i][j]+=b[i][j-1];
        }
    }

    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            for (int x1=1;x1+i<=n;x1++){
                for (int y1=1;y1+j<=m;y1++){
                    int x2=x1+i,y2=y1+j;
                    int tmp=dp[x1][x2][y1][y2];

                    Ans = max(Ans,dp[x1][x2][y1][y2]);
                    int x3=max(1,x2-(u-1)),x4=min(n,x1+(n-u)),y3=max(1,y2-(v-1)),y4=min(m,y1+(m-v));
                    
                    if (x3>x4||y3>y4) continue;
                    
                    if (x1>1&&x3<x1) dp[x1-1][x2][y1][y2] = max(dp[x1-1][x2][y1][y2],tmp+X(x1-1,max(y1,y3),min(y2,y4)));
                    if (x2<n&&x4>x2) dp[x1][x2+1][y1][y2] = max(dp[x1][x2+1][y1][y2],tmp+X(x2+1,max(y1,y3),min(y2,y4)));
                    if (y1>1&&y3<y1) dp[x1][x2][y1-1][y2] = max(dp[x1][x2][y1-1][y2],tmp+Y(y1-1,max(x1,x3),min(x2,x4)));
                    if (y2<m&&y4>y2) dp[x1][x2][y1][y2+1] = max(dp[x1][x2][y1][y2+1],tmp+Y(y2+1,max(x1,x3),min(x2,x4)));
                }
            }
        }
    }
    cout << Ans << "\n";
    // printf("%d\n",(int)Ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:79:64: error: no matching function for call to 'max(short int&, int)'
   79 |                     if (x1>1&&x3<x1) dp[x1-1][x2][y1][y2] = max(dp[x1-1][x2][y1][y2],tmp+X(x1-1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:3:
/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:79:64: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   79 |                     if (x1>1&&x3<x1) dp[x1-1][x2][y1][y2] = max(dp[x1-1][x2][y1][y2],tmp+X(x1-1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:79:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   79 |                     if (x1>1&&x3<x1) dp[x1-1][x2][y1][y2] = max(dp[x1-1][x2][y1][y2],tmp+X(x1-1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:80:64: error: no matching function for call to 'max(short int&, int)'
   80 |                     if (x2<n&&x4>x2) dp[x1][x2+1][y1][y2] = max(dp[x1][x2+1][y1][y2],tmp+X(x2+1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:80:64: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   80 |                     if (x2<n&&x4>x2) dp[x1][x2+1][y1][y2] = max(dp[x1][x2+1][y1][y2],tmp+X(x2+1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:80:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   80 |                     if (x2<n&&x4>x2) dp[x1][x2+1][y1][y2] = max(dp[x1][x2+1][y1][y2],tmp+X(x2+1,max(y1,y3),min(y2,y4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:81:64: error: no matching function for call to 'max(short int&, int)'
   81 |                     if (y1>1&&y3<y1) dp[x1][x2][y1-1][y2] = max(dp[x1][x2][y1-1][y2],tmp+Y(y1-1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:81:64: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   81 |                     if (y1>1&&y3<y1) dp[x1][x2][y1-1][y2] = max(dp[x1][x2][y1-1][y2],tmp+Y(y1-1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:81:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   81 |                     if (y1>1&&y3<y1) dp[x1][x2][y1-1][y2] = max(dp[x1][x2][y1-1][y2],tmp+Y(y1-1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:82:64: error: no matching function for call to 'max(short int&, int)'
   82 |                     if (y2<m&&y4>y2) dp[x1][x2][y1][y2+1] = max(dp[x1][x2][y1][y2+1],tmp+Y(y2+1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:64: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   82 |                     if (y2<m&&y4>y2) dp[x1][x2][y1][y2+1] = max(dp[x1][x2][y1][y2+1],tmp+Y(y2+1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:82:64: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   82 |                     if (y2<m&&y4>y2) dp[x1][x2][y1][y2+1] = max(dp[x1][x2][y1][y2+1],tmp+Y(y2+1,max(x1,x3),min(x2,x4)));
      |                                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~