Submission #869342

# Submission time Handle Problem Language Result Execution time Memory
869342 2023-11-04T05:36:20 Z sleepntsheep Tents (JOI18_tents) C++17
100 / 100
112 ms 36436 KB
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")



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 3050

const ll M = 1000000007;

int h, w;
int 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 time Memory Grader output
1 Correct 6 ms 35676 KB Output is correct
2 Correct 4 ms 35676 KB Output is correct
3 Correct 4 ms 35676 KB Output is correct
4 Correct 4 ms 35676 KB Output is correct
5 Correct 4 ms 35676 KB Output is correct
6 Correct 4 ms 35676 KB Output is correct
7 Correct 5 ms 35676 KB Output is correct
8 Correct 5 ms 35632 KB Output is correct
9 Correct 5 ms 35676 KB Output is correct
10 Correct 4 ms 35676 KB Output is correct
11 Correct 4 ms 35632 KB Output is correct
12 Correct 5 ms 35672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 35676 KB Output is correct
2 Correct 4 ms 35676 KB Output is correct
3 Correct 4 ms 35676 KB Output is correct
4 Correct 4 ms 35676 KB Output is correct
5 Correct 4 ms 35676 KB Output is correct
6 Correct 4 ms 35676 KB Output is correct
7 Correct 5 ms 35676 KB Output is correct
8 Correct 5 ms 35632 KB Output is correct
9 Correct 5 ms 35676 KB Output is correct
10 Correct 4 ms 35676 KB Output is correct
11 Correct 4 ms 35632 KB Output is correct
12 Correct 5 ms 35672 KB Output is correct
13 Correct 4 ms 35676 KB Output is correct
14 Correct 4 ms 35656 KB Output is correct
15 Correct 71 ms 35932 KB Output is correct
16 Correct 8 ms 35672 KB Output is correct
17 Correct 20 ms 35932 KB Output is correct
18 Correct 23 ms 35920 KB Output is correct
19 Correct 83 ms 35932 KB Output is correct
20 Correct 67 ms 35952 KB Output is correct
21 Correct 46 ms 35928 KB Output is correct
22 Correct 45 ms 35720 KB Output is correct
23 Correct 27 ms 35932 KB Output is correct
24 Correct 112 ms 36436 KB Output is correct
25 Correct 84 ms 35948 KB Output is correct
26 Correct 96 ms 35948 KB Output is correct
27 Correct 109 ms 35952 KB Output is correct