Submission #555502

# Submission time Handle Problem Language Result Execution time Memory
555502 2022-05-01T06:05:41 Z wenqi Tents (JOI18_tents) C++17
100 / 100
291 ms 41700 KB
// trans rights

#include <bits/extc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;

constexpr int mod = 1000000007;

int W, H;
int cache[3069][3069];
bool done[3069][3069];

int dp(int i, int j)
{
    if (i <= 0 or j <= 0)
        return 1;
    bool &d = done[i][j];
    int &ans = cache[i][j];
    if (d)
        return ans;
    ans = (4ll * j * dp(i - 1, j - 1) + dp(i - 1, j)) % mod;
    ll B = ((ll) j * (j - 1)) / 2;
    if (i >= 2)
        ans = (ans + (ll) (i - 1) * j * dp(i - 2, j - 1)) % mod;
    if (j >= 2)
        ans = (ans + B * dp(i - 1, j - 2)) % mod;
    d = true;
    return ans;
}

int main(int argc, const char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> W >> H;
    cout << (dp(W, H) - 1 + mod) % mod;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 2 ms 1748 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 2 ms 1860 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 2 ms 2132 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 3 ms 2388 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 2 ms 1748 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 2 ms 1860 KB Output is correct
7 Correct 1 ms 980 KB Output is correct
8 Correct 2 ms 2132 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 3 ms 2388 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 2644 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 8 ms 16660 KB Output is correct
15 Correct 244 ms 37812 KB Output is correct
16 Correct 4 ms 2376 KB Output is correct
17 Correct 19 ms 7136 KB Output is correct
18 Correct 43 ms 12684 KB Output is correct
19 Correct 218 ms 40120 KB Output is correct
20 Correct 175 ms 33228 KB Output is correct
21 Correct 99 ms 21116 KB Output is correct
22 Correct 132 ms 26444 KB Output is correct
23 Correct 85 ms 28876 KB Output is correct
24 Correct 290 ms 41700 KB Output is correct
25 Correct 213 ms 35300 KB Output is correct
26 Correct 267 ms 38732 KB Output is correct
27 Correct 291 ms 40280 KB Output is correct