Submission #767298

# Submission time Handle Problem Language Result Execution time Memory
767298 2023-06-26T15:13:51 Z 1075508020060209tc Tents (JOI18_tents) C++14
100 / 100
83 ms 82768 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
const int mod=1e9+7;
int n;int m;
int dp[5010][5010];
int cn2(int x){
return ((x*(x-1))/2)%mod;
}


signed main(){
cin>>n>>m;
dp[0][m]=1;
for(int H=1;H<=n;H++){
    for(int W=0;W<=m;W++){

        dp[H][W]=dp[H-1][W];

        dp[H][W]=(dp[H][W]+dp[H-1][W+1]*4*(W+1) )%mod;

        dp[H][W]=(dp[H][W]+dp[H-1][W+2]*cn2(W+2))%mod;

        if(H>=2){
            dp[H][W]=(dp[H][W]+dp[H-2][W+1]*(W+1)%mod*(H-1))%mod;
        }
    }
}
int ans=0;
for(int i=0;i<=m-1;i++){
    ans=(ans+dp[n][i])%mod;
}
cout<<ans<<endl;



}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1064 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 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 2228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 1064 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 1364 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 1748 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 2228 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 4 ms 9652 KB Output is correct
15 Correct 52 ms 55148 KB Output is correct
16 Correct 6 ms 4052 KB Output is correct
17 Correct 16 ms 12828 KB Output is correct
18 Correct 16 ms 17104 KB Output is correct
19 Correct 66 ms 63152 KB Output is correct
20 Correct 49 ms 50844 KB Output is correct
21 Correct 32 ms 33740 KB Output is correct
22 Correct 33 ms 35500 KB Output is correct
23 Correct 21 ms 27072 KB Output is correct
24 Correct 82 ms 82768 KB Output is correct
25 Correct 62 ms 62912 KB Output is correct
26 Correct 69 ms 71448 KB Output is correct
27 Correct 83 ms 79920 KB Output is correct