Submission #746493

# Submission time Handle Problem Language Result Execution time Memory
746493 2023-05-22T14:18:45 Z Sami_Massah Tents (JOI18_tents) C++17
100 / 100
87 ms 71008 KB
#include <bits/stdc++.h>
using namespace std;


const long long maxn = 3e3 + 12, mod = 1e9 + 7, inf = 1e9 + 12 ;
long long n, m, dp[maxn][maxn];
int main(){
    cin >> n >> m;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++)
        dp[i][0] = 1;
    for(int j = 1; 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][j - 1];
            dp[i][j] += i * dp[i - 1][j - 1] * 4;

            if(j >= 2)
                dp[i][j] += i * (j - 1) * dp[i - 1][j - 2];
            if(i >= 2)
                dp[i][j] += (i * (i - 1) / 2) * dp[i - 2][j - 1];
            dp[i][j] %= mod;
        //    cout << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    cout << (dp[n][m] - 1 + mod * 2) % mod << endl;


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 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 1340 KB Output is correct
9 Correct 1 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 1 ms 308 KB Output is correct
2 Correct 1 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 1340 KB Output is correct
9 Correct 1 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 4 ms 9556 KB Output is correct
15 Correct 61 ms 55056 KB Output is correct
16 Correct 4 ms 4052 KB Output is correct
17 Correct 14 ms 12756 KB Output is correct
18 Correct 18 ms 16964 KB Output is correct
19 Correct 69 ms 62852 KB Output is correct
20 Correct 55 ms 50844 KB Output is correct
21 Correct 40 ms 33740 KB Output is correct
22 Correct 42 ms 35340 KB Output is correct
23 Correct 25 ms 27028 KB Output is correct
24 Correct 87 ms 71008 KB Output is correct
25 Correct 70 ms 61420 KB Output is correct
26 Correct 77 ms 66676 KB Output is correct
27 Correct 84 ms 69108 KB Output is correct