Language: C++

#include<bits/stdc++.h>
using namespace std;

using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vvvvvi=vector<vvvvi>;

using ll=long long;
const ll INF=1e15;

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    vector<ll> b(m);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    vvvvvi dp(2,vvvvi(n+1,vvvi(m+1,vvi(n+1,vi(m+1)))));
    for(int ap=0;ap<=n;ap++){
        for(int bp=0;bp<=m;bp++){
            for(int ar=0;ar<=n;ar++){
                for(int br=0;br<=m;br++){
                    dp[0][ap][bp][ar][br]=-INF;
                    dp[1][ap][bp][ar][br]=INF;
                }
            }
        }
    }
    dp[0][n][m][n][m]=0;
    dp[1][n][m][n][m]=0;
    vector<int> sumva(n+1);
    for(int i=0;i<n;i++){
        sumva[i+1]=sumva[i]+max(0LL,a[i]);
    }
    vector<int> sumvb(m+1);
    for(int i=0;i<m;i++){
        sumvb[i+1]=sumvb[i]+max(0LL,b[i]);
    }
    auto sumA=[&](int l,int r){return sumva[r]-sumva[l];};
    auto sumB=[&](int l,int r){return sumvb[r]-sumvb[l];};
    //cerr<<"#"<<endl;
    function<ll(int,int,int,int,int)> dfs=[&](int turn,int ap,int bp,int ar,int br){
        if(abs(dp[turn][ap][bp][ar][br])!=INF) return dp[turn][ap][bp][ar][br];
        ll res=dp[turn][ap][bp][ar][br];
        if(turn+ap+bp+ar+br!=0 && ap==ar && bp==br) res=0;
        if(turn+ap+bp+ar+br==0) res=max(res,dfs(1,ap,bp,ar,br));
        if(turn==0){
            if(ap<n){
                if(a[ap]==-1) res=max(res,dfs(1,ap+1,bp,ar,bp));
                else res=max(res,dfs(1,ap+1,bp,ar,br));
            }
            if(ap!=ar || bp!=br) res=max(res,dfs(1,ap,bp,ap,bp)+sumA(ar,ap)-sumB(br,bp));
        }
        else{
            if(bp<m){
                if(b[bp]==-1) res=min(res,dfs(0,ap,bp+1,ap,br));
                else res=min(res,dfs(0,ap,bp+1,ar,br));
            }
            if(ap!=ar || bp!=br) res=min(res,dfs(0,ap,bp,ap,bp)+sumA(ar,ap)-sumB(br,bp));
        }
        //cerr<<turn<<" "<<ap<<" "<<bp<<" "<<ar<<" "<<br<<" "<<res<<endl;
        return dp[turn][ap][bp][ar][br]=res;
    };
    cout<<dfs(0,0,0,0,0)<<endl;
    return 0;
}


Compiler output:
a.cc:4:17: error: 'll' was not declared in this scope
    4 | using vi=vector<ll>;
      |                 ^~
a.cc:4:19: error: template argument 1 is invalid
    4 | using vi=vector<ll>;
      |                   ^
a.cc:4:19: error: template argument 2 is invalid
a.cc:5:18: error: 'vi' was not declared in this scope
    5 | using vvi=vector<vi>;
      |                  ^~
a.cc:5:20: error: template argument 1 is invalid
    5 | using vvi=vector<vi>;
      |                    ^
a.cc:5:20: error: template argument 2 is invalid
a.cc:6:19: error: 'vvi' was not declared in this scope
    6 | using vvvi=vector<vvi>;
      |                   ^~~
a.cc:6:22: error: template argument 1 is invalid
    6 | using vvvi=vector<vvi>;
      |                      ^
a.cc:6:22: error: template argument 2 is invalid
a.cc:7:20: error: 'vvvi' was not declared in this scope
    7 | using vvvvi=vector<vvvi>;
      |                    ^~~~
a.cc:7:24: error: template argument 1 is invalid
    7 | using vvvvi=vector<vvvi>;
      |                        ^
a.cc:7:24: error: template argument 2 is invalid
a.cc:8:21: error: 'vvvvi' was not declared in this scope
    8 | using vvvvvi=vector<vvvvi>;
      |                     ^~~~~
a.cc:8:26: error: template argument 1 is invalid
    8 | using vvvvvi=vector<vvvvi>;
      |                          ^
a.cc:8:26: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:20:5: error: 'vvvvvi' was not declared in this scope
   20 |     vvvvvi dp(2,vvvvi(n+1,vvvi(m+1,vvi(n+1,vi(m+1)))));
      |     ^~~~~~
a.cc:25:21: error: 'dp' was not declared in this scope; did you mean 'bp'?
   25 |                     dp[0][ap][bp][ar][br]=-INF;
      |                     ^~
      |                     bp
a.cc:31:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   31 |     dp[0][n][m][n][m]=0;
      |     ^~
      |     dup
a.cc:44:43: error: conversion from 'main()::<lambda(int, int, int, int, int)>' to non-scalar type 'std::function<long long int(int, int, int, int, int)>' requested
   44 |     function<ll(int,int,int,int,int)> dfs=[&](int turn,int ap,int bp,int ar,int br){
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |         if(abs(dp[turn][ap][bp][ar][br])!=INF) return dp[turn][ap][bp][ar][br];
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   46 |         ll res=dp[turn][ap][bp][ar][br];
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   47 |         if(turn+ap+bp+ar+br!=0 && ap==ar && bp==br) res=0;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   48 |         if(turn+ap+bp+ar+br==0) res=max(res,dfs(1,ap,bp,ar,br));
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   49 |         if(turn==0){
      |         ~~~~~~~~~~~~                       
   50 |             if(ap<n){
      |             ~~~~~~~~~                      
   51 |                 if(a[ap]==-1) res=max(res,dfs(1,ap+1,bp,ar,bp));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   52 |                 else res=max(res,dfs(1,ap+1,bp,ar,br));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   53 |             }
      |             ~                              
   54 |             if(ap!=ar || bp!=br) res=max(res,dfs(1,ap,bp,ap,bp)+sumA(ar,ap)-sumB(br,bp));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |         }
      |         ~                                  
   56 |         else{
      |         ~~~~~                              
   57 |             if(bp<m){
      |             ~~~~~~~~~                      
   58 |                 if(b[bp]==-1) res=min(res,dfs(0,ap,bp+1,ap,br));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59 |                 else res=min(res,dfs(0,ap,bp+1,ar,br));
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 |             }
      |             ~                              
   61 |             if(ap!=ar || bp!=br) res=min(res,dfs(0,ap,bp,ap,bp)+sumA(ar,ap)-sumB(br,bp));
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 |         }
      |         ~                                  
   63 |         //cerr<<turn<<" "<<ap<<" "<<bp<<" "<<ar<<" "<<br<<" "<<res<<endl;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 |         return dp[turn][ap][bp][ar][br]=res;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 |     };
      |     ~