| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1256676 | nanaseyuzuki | Tents (JOI18_tents) | C++20 | 16 ms | 35672 KiB | 
#include <bits/stdc++.h>
/*
    --> Author: Kazuki_Hoshino__8703 <--
    I love Nanasaki Ai ☆*: .。. o(≒_≒)o .。.:☆
*/
#define fi first
#define se second
#define pii pair<int, int>
#define ll long long
using namespace std;
const int mn = 3e3 + 5, bm = (1 << 11) + 1, mod = 1e9 + 7, offset = 5e4;
const int inf = 1e9, base = 311;
int H, W, dp[mn][mn];
int f(int i, int j){
    if(dp[i][j] != -1) return dp[i][j];
    if(i <= 0 || j <= 0) return 1;
    dp[i][j] = 0;
    // dp[i][j] : xét hàng thứ i và còn j hàng chưa sử dụng
    if(j >= 2) dp[i][j] += f(i - 1, j - 2) * j * (j - 1) / 2;
    dp[i][j] %= mod;
    if(i >= 2) dp[i][j] += f(i - 2, j - 1) * (i - 1) * j;
    dp[i][j] %= mod;
    dp[i][j] += f(i - 1, j - 1) * j * 4;
    dp[i][j] %= mod;
    dp[i][j] += f(i - 1, j);
    dp[i][j] %= mod;
    return dp[i][j];
}
void solve(){
    cin >> H >> W;
    memset(dp, -1, sizeof(dp));
    cout << f(H, W) - 1 << '\n';
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if(fopen("ROBOT.INP", "r")) {
        freopen("ROBOT.INP", "r", stdin);
        freopen("ROBOT.OUT", "w", stdout);
    }
    int t = 1;
    // cin >> t;
    while(t--) {
        solve();
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
