제출 #916146

#제출 시각아이디문제언어결과실행 시간메모리
916146a_l_i_r_e_z_aTents (JOI18_tents)C++17
100 / 100
90 ms70992 KiB
// In the name of God
// Hope is last to die

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

const int maxn = 3000 + 5;
const int inf = 1e9 + 7, mod = 1e9 + 7;
ll n, m, dp[maxn][maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m;
    for(int i = 0; i <= m; i++) dp[0][i] = 1;
    for(int i = 1; i <= n; i++){
        dp[i][0] = 1;
        for(int j = 1; j <= m; j++){
            dp[i][j] = dp[i - 1][j];
            ll c;
            if(j > 1){
                c = (j * (j - 1)) / 2;
                c %= mod;
                c = (c * dp[i - 1][j - 2]) % mod;
                dp[i][j] = (dp[i][j] + c) % mod;
            }
            c = (j * 4 * dp[i - 1][j - 1]) % mod; 
            dp[i][j] = (dp[i][j] + c) % mod;
            if(i > 1){
                c = j * (i - 1) * dp[i - 2][j - 1];
                c %= mod;
                dp[i][j] = (dp[i][j] + c) % mod;
            }
        }
    }
    cout << (dp[n][m] + mod - 1) % mod << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...