COFO::1288C Two Arrays

Problem

Point

Design

Complexity

Code

#include<bits/stdc++.h>
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(int i = (a); i <(b); i++)
#define r_rep(i, a, b) for(int i = (a); i >(b); i--)
typedef long long ll;
using namespace std;
ll MOD = 1e9 + 7;
ll asc[11][1001]; // asc[i][j] : max(a) = j이고, 길이가 i일때 non-decreasing의 갯수 % 1e9 + 7
ll dsc[11][1001]; // dsc[i][j] : max(a) = j이고, 길이가 i일때 non-increasing의 갯수 % 1e9 + 7

int n, m;
void solve(){
    cin >> n >> m;
    rep(j, 1, n + 1) asc[1][j] = 1;
    rep(i, 2, m + 1) rep(j, 1, n+1) asc[i][j] = (asc[i-1][j] + asc[i][j-1]) % MOD;
    rep(i, 1, m + 1) rep(j, 1, n+1) dsc[i][j] = (dsc[i][j-1] + asc[i][j]) % MOD;
    
    
    ll ans = 0;
    rep(i, 1, n + 1)
        ans = (ans + asc[m][i] * dsc[m][n - i + 1]) % MOD;
    
    cout << ans << '\n';
}
int main(){
    freopen("input.txt", "r", stdin);
    //int tc; cin >> tc;
    //while(tc--)
        solve();
    return 0;
}