Submission #1033997

#TimeUsernameProblemLanguageResultExecution timeMemory
1033997vjudge1Tents (JOI18_tents)C++14
100 / 100
121 ms70908 KiB
#include<bits/stdc++.h> using namespace std; #define int long long signed main(){ int n,m; cin >> n >> m; const int mod=1e9+7; int DP[n+1][m+1]; for(int j=0;j<=m;j++){ DP[0][j]=1; } for(int i=1;i<=n;i++){ for(int j=0;j<=m;j++){ DP[i][j]=0; if(i>1&&j>0){ DP[i][j]+=(DP[i-2][j-1]*((j*(i-1))%mod)); DP[i][j]%=mod; } if(j>1){ DP[i][j]=(DP[i][j]+((DP[i-1][j-2]*((j*(j-1)/2)%mod))%mod)); DP[i][j]%=mod; } if(j>0){ DP[i][j]=(DP[i][j]+((4*DP[i-1][j-1]*j)%mod)); DP[i][j]%=mod; } DP[i][j]+=DP[i-1][j]; DP[i][j]%=mod; } } cout << (DP[n][m]+mod-1)%mod; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...