Submission #914379

#TimeUsernameProblemLanguageResultExecution timeMemory
914379AndreyTents (JOI18_tents)C++14
100 / 100
73 ms70748 KiB
#include<bits/stdc++.h> using namespace std; const long long MOD = 1e9+7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,m; cin >> n >> m; long long dp[n+1][m+1]; for(long long i = 0; i <= m; i++) { dp[0][i] = 1; } for(long long i = 0; i <= n; i++) { dp[i][0] = 1; } for(long long i = 1; i <= n; i++) { for(long long j = 1; j <= m; j++) { dp[i][j] = 0; dp[i][j]+=dp[i-1][j]; if(j >= 2) { dp[i][j]+=(((j*(j-1)/2))%MOD)*dp[i-1][j-2]; } dp[i][j]+=4*j*dp[i-1][j-1]; if(i >= 2) { dp[i][j]+=j*(i-1)*dp[i-2][j-1]; } dp[i][j]%=MOD; } } cout << (dp[n][m]-1+MOD)%MOD; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...