Submission #948890

#TimeUsernameProblemLanguageResultExecution timeMemory
948890starchanTents (JOI18_tents)C++17
100 / 100
116 ms71356 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) const int mod = 1e9+7; int c2(int j) { return ((j*(j-1))/2)%mod; } signed main() { fast(); int n, m; cin >> n >> m; int dp[n+10][m+10]; for(int i = 0; i <= n+9; i++) dp[i][0] = 1; for(int i = 0; i <= m+9; i++) dp[0][i] = 1; for(int i = 1; i <= n+9; i++) dp[i][1] = (1 + (4*i) + c2(i))%mod; for(int i = 1; i <= m+9; i++) dp[1][i] = (1 + (4*i) + c2(i))%mod; for(int i = 2; i <= n+9; i++) { for(int j = 2; j <= m+9; j++) { dp[i][j] = ((dp[i-1][j]%mod)+((4*j*dp[i-1][j-1])%mod)+(c2(j)*dp[i-1][j-2])%mod)%mod; dp[i][j]+=(((i-1)*j*dp[i-2][j-1])%mod); dp[i][j]%=mod; } } dp[n][m]+=(mod-1); dp[n][m]%=mod; cout << dp[n][m] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...