제출 #43984

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
439842018-03-29 06:44:23ruhanhabib39Tents (JOI18_tents)C++17
100 / 100
122 ms71340 KiB
#include <bits/stdc++.h>
using namespace std;
const int MX = 3000;
const long long MOD = 1e9 + 7;
long long dp[MX + 10][MX + 10];
long long calc(long long H, long long W) {
for(int w = 0; w <= W; w++) {
dp[0][w] = 1;
}
for(int h = 0; h <= H; h++) {
dp[h][0] = 1;
}
for(int h = 1; h <= H; h++) {
for(int w = 1; w <= W; w++) {
long long zero = dp[h-1][w];
long long one = 4*w * dp[h-1][w-1] % MOD;
long long two_horiz = 0, two_vert = 0;
if(w >= 2) two_horiz = w*(w - 1) / 2 * dp[h-1][w-2] % MOD;
if(h >= 2) two_vert = w * (h - 1) * dp[h-2][w-1] % MOD;
dp[h][w] = (zero + one + two_horiz + two_vert) % MOD;
}
}
return dp[H][W];
}
int main() {
long long H, W; cin >> H >> W;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...