제출 #237171

#제출 시각아이디문제언어결과실행 시간메모리
237171FalconTents (JOI18_tents)C++14
100 / 100
437 ms72312 KiB
#include <bits/stdc++.h>

#define __DEBUG 0
#define all(c) (c).begin(), (c).end()
#define tr(c, it) for(auto it = c.begin(); it != c.end(); it++)
#define setAll(x, k) memset(x, k, sizeof(x))
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, s, e) for(int i = s; i <= e; i++)
#define rep3(i, s, e, d) for(int i = s; d >= 0 ? i <= e : i >= e; i += d)
#define pb push_back
#define DBG2(x) if(__DEBUG) cerr << "<" << __LINE__ << "> " << #x << ": " << x << endl
#define DBG if(__DEBUG) cerr
#define pii pair<int, int>

#define int ll

using namespace std;

typedef long long ll;

const int mod = 1000000007;


int dp[3001][3001];
bool ch[3001][3001];

int rec(int H, int W){
	if(H < 0 || W < 0)
		return 0;
	if(W == 0 || H == 0)
		return 1;
	if(ch[H][W])
		return dp[H][W];
	ch[H][W] = 1;
	return dp[H][W] = ((rec(H, W - 1) + H * (H - 1) / 2 * rec(H - 2, W - 1) % mod) % mod 
		+ (H * (W - 1) * rec(H - 1, W - 2) % mod + 4 * H * rec(H - 1, W - 1) % mod) % mod) % mod;

}

signed main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr), cout.tie(nullptr);

#if __DEBUG
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("debug", "w", stderr);
#endif

	int H, W;
	cin >> H >> W;
	cout << rec(H, W) - 1 << endl;
 
	
#if __DEBUG
	system(R"(notepad .\out)");
#endif
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...