제출 #869341

#제출 시각아이디문제언어결과실행 시간메모리
869341sleepntsheepTents (JOI18_tents)C++17
48 / 100
1 ms1188 KiB
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 305

const ll M = 1000000007;

int h, w;
ll dp[N][N];

int main()
{
    ShinLena;
    cin >> h >> w;
    for (int i = 0; i < N; ++i) dp[0][i] = dp[i][0] = 1;
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j)
    {
        (dp[i][j] += dp[i-1][j] + (4ll * j * dp[i-1][j-1] % M)) %= M;
        if (i > 1) (dp[i][j] += (1ll*(i-1)*j%M) * dp[i-2][j-1] % M) %= M;
        if (j > 1) (dp[i][j] += (1ll*j*(j-1)%M*500000004%M) * dp[i-1][j-2] % M) %= M;
    }
    cout << (dp[h][w] + M - 1) % M << endl;
    return 0;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...