제출 #1237158

#제출 시각아이디문제언어결과실행 시간메모리
1237158antromancapTents (JOI18_tents)C++20
100 / 100
213 ms71156 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 3001, MOD = 1e9 + 7;
int n, m;
long long f[N][N];

long long calc(int i, int j) {
	if (i <= 0 || j <= 0) return 1;
	if (f[i][j] != -1) return f[i][j];
	long long &res = (f[i][j] = 0);
	(res += calc(i - 1, j)) %= MOD;
	(res += calc(i - 1, j - 1) * 4 * j) %= MOD;
	(res += calc(i - 1, j - 2) * j * (j - 1) / 2) %= MOD;
	(res += calc(i - 2, j - 1) * (i - 1) * j) %= MOD;
	return res;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	memset(f, -1, sizeof f);
	cout << calc(n, m) - 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...