Submission #798196

# Submission time Handle Problem Language Result Execution time Memory
798196 2023-07-30T13:14:59 Z vjudge1 Tents (JOI18_tents) C++14
100 / 100
59 ms 70684 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 3000, mod = 1e9 + 7 ;
ll dp[N + 1][N + 1] ;
signed main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
    ll n, m ;
    cin >> n >> m ;
    for(ll j = 0 ; j <= N ; j++)
        dp[0][j] = dp[j][0] = 1 ;
    for(ll i = 1 ; i <= n ; i++)
        for(ll j = 1 ; j <= m ; j++)
        {
            dp[i][j] += dp[i - 1][j] ;
            dp[i][j] += dp[i - 1][j - 1] * 4ll * j ;
            if(j >= 2)
                dp[i][j] += dp[i - 1][j - 2] * (j * (j - 1) / 2ll) ;
            if(i >= 2)
                dp[i][j] += dp[i - 2][j - 1] * (j * (i - 1)) ;
            dp[i][j] %= mod ;
        }
    cout << (dp[n][m] - 1 + mod) % mod ;
    return 0 ;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12372 KB Output is correct
2 Correct 5 ms 12372 KB Output is correct
3 Correct 6 ms 12356 KB Output is correct
4 Correct 5 ms 12484 KB Output is correct
5 Correct 5 ms 12500 KB Output is correct
6 Correct 5 ms 12628 KB Output is correct
7 Correct 5 ms 12616 KB Output is correct
8 Correct 5 ms 12500 KB Output is correct
9 Correct 5 ms 12484 KB Output is correct
10 Correct 5 ms 12740 KB Output is correct
11 Correct 5 ms 12500 KB Output is correct
12 Correct 5 ms 13140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 12372 KB Output is correct
2 Correct 5 ms 12372 KB Output is correct
3 Correct 6 ms 12356 KB Output is correct
4 Correct 5 ms 12484 KB Output is correct
5 Correct 5 ms 12500 KB Output is correct
6 Correct 5 ms 12628 KB Output is correct
7 Correct 5 ms 12616 KB Output is correct
8 Correct 5 ms 12500 KB Output is correct
9 Correct 5 ms 12484 KB Output is correct
10 Correct 5 ms 12740 KB Output is correct
11 Correct 5 ms 12500 KB Output is correct
12 Correct 5 ms 13140 KB Output is correct
13 Correct 5 ms 12492 KB Output is correct
14 Correct 5 ms 12500 KB Output is correct
15 Correct 44 ms 56092 KB Output is correct
16 Correct 8 ms 15172 KB Output is correct
17 Correct 17 ms 22208 KB Output is correct
18 Correct 16 ms 24532 KB Output is correct
19 Correct 50 ms 63304 KB Output is correct
20 Correct 41 ms 53016 KB Output is correct
21 Correct 29 ms 39200 KB Output is correct
22 Correct 38 ms 38864 KB Output is correct
23 Correct 19 ms 27092 KB Output is correct
24 Correct 59 ms 70684 KB Output is correct
25 Correct 49 ms 62808 KB Output is correct
26 Correct 53 ms 67156 KB Output is correct
27 Correct 58 ms 69220 KB Output is correct