Submission #833120

# Submission time Handle Problem Language Result Execution time Memory
833120 2023-08-22T01:35:06 Z exodus_ Tents (JOI18_tents) C++14
100 / 100
158 ms 82728 KB
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long dp[4004][4004];
int main() {
    int n,m;
    cin >> n >> m;
    for(int i=0; i<=m; i++) {
        dp[0][i] = 1;
    }
    for(int i=1; i<=n; i++) {
        for(int j=0; j<=m; j++) {
            dp[i][j] += dp[i-1][j];
            if(j>=1) {
                dp[i][j] += ((dp[i-1][j-1] * j)%mod * 4)%mod;
                dp[i][j] %= mod;
            }
            if(j>=1 && i>=2) {
                dp[i][j] += ((dp[i-2][j-1] * j)%mod * (i-1))%mod;
                dp[i][j] %= mod;
            }
            if(i>=1 && j>=2) {
                dp[i][j] += (dp[i-1][j-2] * (j*(j-1)/2)%mod)%mod;
                dp[i][j] %= mod;
            }
        }
    }
    cout << dp[n][m]-1 << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 1076 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 1332 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 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 212 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 1076 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 1332 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 2 ms 1748 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 2132 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 5 ms 9556 KB Output is correct
15 Correct 101 ms 55144 KB Output is correct
16 Correct 7 ms 4016 KB Output is correct
17 Correct 22 ms 12804 KB Output is correct
18 Correct 29 ms 17020 KB Output is correct
19 Correct 113 ms 62896 KB Output is correct
20 Correct 108 ms 50924 KB Output is correct
21 Correct 58 ms 33804 KB Output is correct
22 Correct 58 ms 35432 KB Output is correct
23 Correct 35 ms 27104 KB Output is correct
24 Correct 158 ms 82728 KB Output is correct
25 Correct 114 ms 62896 KB Output is correct
26 Correct 131 ms 71372 KB Output is correct
27 Correct 147 ms 79692 KB Output is correct