Submission #523413

#TimeUsernameProblemLanguageResultExecution timeMemory
523413CPSCTents (JOI18_tents)C++14
100 / 100
134 ms70836 KiB
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
using namespace std;
const int N = 3005, mod = 1e9 + 7;
int n,m,dp[N][N];
int C(int n, int k) {
    return (n*(n - 1)) / 2;
}
main() {
    cin>>n>>m;
    for (int i = 0; i <= max(n,m); i++) dp[0][i] = dp[i][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] += dp[i - 1][j];
            if (j >= 2)
            dp[i][j] += dp[i - 1][j - 2] * C(j,2);
            dp[i][j] %= mod;
           
            dp[i][j] += dp[i - 1][j - 1] * 4*j;dp[i][j] %= mod;
            if (i >= 2)
            dp[i][j] += dp[i - 2][j - 1] * j * (i - 1);
            dp[i][j] %= mod;
        }
    }
    dp[n][m] --;
    if (dp[n][m] < 0) dp[n][m] += mod;
    cout<<dp[n][m]<<endl;
}

Compilation message (stderr)

tents.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...