Submission #335373

#TimeUsernameProblemLanguageResultExecution timeMemory
335373amoo_safarTents (JOI18_tents)C++17
100 / 100
152 ms71404 KiB
// vaziat meshki-ghermeze !
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 3e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}

ll dp[N][N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fill(dp[0], dp[0] + N, 1);
	for(int i = 1; i < N; i++){
		dp[i][0] = 1;
		for(int j = 1; j < N; j++){
			dp[i][j] = dp[i - 1][j];
			dp[i][j] += mul(dp[i - 1][j - 1], mul(j, 4));

			if(i >= 2)
				dp[i][j] += mul(dp[i - 2][j - 1], mul(j, (i - 1)));
			if(j >= 2)
				dp[i][j] += mul(dp[i - 1][j - 2], 1ll * j * (j - 1) / 2ll);
			dp[i][j] %= Mod;
		}
	}
	debug(dp[1][1]);
	ll W, H;
	cin >> W >> H;
	cout << dp[W][H]-1 << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...