Language: C++

#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define mp(x,y) make_pair(x,y)
#define ALL(a) a.begin(),a.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define pii pair<int,int>
#define INF 1<<29
#define MAX 
using namespace std;

int n,m,dp[2020][2020][2];
string s,t;

int dfs(int o,int d,int odd){
 if(dp[o][d][odd]>=0) return dp[o][d][odd];
 int ma=0;
 if(odd){
  if(o<n&&s[o]=='O') ma=max(ma,dfs(o+1,d,odd^1)+1);
  if(d<m&&t[d]=='O') ma=max(ma,dfs(o,d+1,odd^1)+1);
 }
 else{
  if(o<n&&s[o]!='O') ma=max(ma,dfs(o+1,d,odd^1)+1);
  if(d<m&&t[d]!='O') ma=max(ma,dfs(o,d+1,odd^1)+1);
 }
 if(o<n) ma=max(ma,max(dfs(o+1,d,odd));
 if(d<n) ma=max(ma,max(dfs(o,d+1,odd));
 return dp[o][d][odd]=ma;
}

void solve(){
 cin>>n>>m;
 cin>>s;
 cin>>t;
 FOR(i,n+1) FOR(j,m+1) FOR(k,2) dp[i][j][k]=-1;
 int p=dfs(0,0,0);
 if(!p||(p&1)) cout<<p<<endl;
 else cout<<p-1<<endl;
}

int main(){
 solve();
 return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int)':
a.cc:30:23: error: no matching function for call to 'max(int)'
   30 |  if(o<n) ma=max(ma,max(dfs(o+1,d,odd));
      |                    ~~~^~~~~~~~~~~~~~~~
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: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:
/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:30:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |  if(o<n) ma=max(ma,max(dfs(o+1,d,odd));
      |                    ~~~^~~~~~~~~~~~~~~~
/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:31:23: error: no matching function for call to 'max(int)'
   31 |  if(d<n) ma=max(ma,max(dfs(o,d+1,odd));
      |                    ~~~^~~~~~~~~~~~~~~~
/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:31:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |  if(d<n) ma=max(ma,max(dfs(o,d+1,odd));
      |                    ~~~^~~~~~~~~~~~~~~~
/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