【题目链接】
【思路要点】
- 直接应用 Lindström–Gessel–Viennot lemma 即可。
- 时间复杂度 O ( N ∗ M ) O(N*M) O(N∗M) 。
【代码】
#include<bits/stdc++.h> using namespace std; const int MAXN = 3005; const int P = 1e9 + 7; typedef long long ll; typedef long double ld; typedef unsigned long long ull; template <typename T> void chkmax(T &x, T y) { x = max(x, y); } template <typename T> void chkmin(T &x