Submission #798141

# Submission time Handle Problem Language Result Execution time Memory
798141 2023-07-30T11:49:18 Z vjudge1 Tents (JOI18_tents) C++17
100 / 100
89 ms 70900 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 3000;
const int MOD = 1e9 + 7;
ll dp[N + 10][N + 10];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i <= n; i++) dp[i][0] = 1;
    for(int j = 0; j <= m; j++) dp[0][j] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            dp[i][j] += dp[i - 1][j];
            dp[i][j] += 4 * j * dp[i - 1][j - 1] % MOD;
            if(j > 1) dp[i][j] += j * (j - 1) / 2 * dp[i - 1][j - 2] % MOD;
            if(i > 1) dp[i][j] += (i - 1) * j * dp[i - 2][j - 1] % MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << (dp[n][m] - 1 + MOD) % MOD;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 0 ms 724 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 2 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 1364 KB Output is correct
7 Correct 1 ms 724 KB Output is correct
8 Correct 1 ms 1364 KB Output is correct
9 Correct 0 ms 724 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 2 ms 2132 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 3 ms 9684 KB Output is correct
15 Correct 62 ms 55112 KB Output is correct
16 Correct 4 ms 4052 KB Output is correct
17 Correct 17 ms 12756 KB Output is correct
18 Correct 18 ms 16980 KB Output is correct
19 Correct 71 ms 63088 KB Output is correct
20 Correct 56 ms 50896 KB Output is correct
21 Correct 43 ms 33808 KB Output is correct
22 Correct 38 ms 35356 KB Output is correct
23 Correct 25 ms 27084 KB Output is correct
24 Correct 89 ms 70900 KB Output is correct
25 Correct 71 ms 61292 KB Output is correct
26 Correct 81 ms 66832 KB Output is correct
27 Correct 89 ms 69020 KB Output is correct