제출 #887745

#제출 시각아이디문제언어결과실행 시간메모리
887745vjudge1Tents (JOI18_tents)C++17
100 / 100
63 ms70980 KiB
#include <bits/stdc++.h>
#define pb push_back
#define dbg(x) cout << "reached here " << x << endl;
#define f first
#define s second
#define ll long long

using namespace std;
typedef pair<int, int> pii;

const int maxn = 3005, mod = 1e9+7;
ll dp[maxn][maxn];

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int h, w;
	cin >> h >> w;

	for (int i = 1; i <= h; ++i)
		dp[i][1] = 4*i + i*(i-1)/2;
	for (int i = 1; i <= w; ++i)
		dp[1][i] = 4*i + i*(i-1)/2;

	for (int i = 2; i <= h; ++i)
		for (int j = 2; j <= w; ++j)
			dp[i][j] = (dp[i][j-1] + (i*(i-1)/2)*(dp[i-2][j-1]+1) + i*(4*(dp[i-1][j-1]+1) + (j-1)*(dp[i-1][j-2]+1))) % mod;

	cout << dp[h][w] << endl;
		
	return 0;
} 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...