题意:
问有多少个矩阵A满足如下性质
* Ai, j ∈ {0, 1, 2} for all 1 ≤ i ≤ n, 1 ≤ j ≤ m.
* Ai, j ≤ Ai + 1, j for all 1 ≤ i < n, 1 ≤ j ≤ m.
* Ai, j ≤ Ai, j + 1 for all 1 ≤ i ≤ n, 1 ≤ j < m.
思路:找0,1;1,2的分割线,求路线不重合的路径数(即严格不相交路径)。套Lindström–Gessel–Viennot引理
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2005;
const int MOD=1e9+7;
//ll a[N],sum[N],dis[N];
int a[200][200];
ll c[N][N];
void init(){
c[0][0]=c[1][0]=c[1][1]=1;
for(int i=2;i<=2000;i++){
c[i][0]=1;
for(int j=1;j<=i;j++) c[i][j]=c[i-1][j]+c[i-1][j-1],c[i][j]%=MOD;
}
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
init();
ll n,m;
while(cin>>n>>m){
ll ans=c[n+m][n]*c[n+m][m]%MOD-c[n+m][n-1]*c[n+m][m-1]%MOD;
ans%=MOD;
ans+=MOD;
cout << ans%MOD << endl;
}
return 0;
}