Submission #288148

# Submission time Handle Problem Language Result Execution time Memory
288148 2020-09-01T09:11:30 Z ngotienhung Tents (JOI18_tents) C++14
100 / 100
216 ms 70904 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

const int maxN = 3005;
const int mod = 1e9 + 7;

int n,m;
int f[maxN][maxN];

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(); cout.tie();

    cin >> m >> n;

    for(int i = 0; i <= m; ++i)
        f[i][0] = 1;
    for(int i = 0; i <= n; ++i)
        f[0][i] = 1;

    for(int i = 1; i <= m; ++i){
        for(int j = 1; j <= n; ++j){
            f[i][j] = (f[i][j] + f[i - 1][j]) % mod;
            f[i][j] = (f[i][j] + f[i - 1][j - 1] * 4 % mod * j % mod) % mod;
            if(j >= 2)
            f[i][j] = (f[i][j] + f[i - 1][j - 2] * (j*(j - 1)/2 % mod)) % mod;
            if(i >= 2)
            f[i][j] = (f[i][j] + f[i - 2][j - 1] * j % mod * (i - 1) % mod) % mod;
        }
    }

    cout << (f[m][n] - 1 + mod) % mod;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 896 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 896 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 2304 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 5 ms 9728 KB Output is correct
15 Correct 139 ms 55228 KB Output is correct
16 Correct 10 ms 4096 KB Output is correct
17 Correct 31 ms 12920 KB Output is correct
18 Correct 40 ms 17144 KB Output is correct
19 Correct 165 ms 62980 KB Output is correct
20 Correct 131 ms 50936 KB Output is correct
21 Correct 86 ms 33788 KB Output is correct
22 Correct 86 ms 35576 KB Output is correct
23 Correct 51 ms 27128 KB Output is correct
24 Correct 216 ms 70904 KB Output is correct
25 Correct 174 ms 61304 KB Output is correct
26 Correct 185 ms 66808 KB Output is correct
27 Correct 204 ms 68984 KB Output is correct