Submission #917928

#TimeUsernameProblemLanguageResultExecution timeMemory
917928EquinoxTents (JOI18_tents)C++17
100 / 100
61 ms71120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<double,double> pdd; //typedef complex<double> cpx; #define fastio cin.tie(0)->sync_with_stdio(0); cout.tie(0); #define all(x) x.begin(),x.end() #define compress(x) x.erase(unique(all(x)),x.end()) #define ff first #define ss second #define INF 1e17 #define MAX 500010 #define SIZE 10010 #define MOD 1000000007 const ll mod = 1e9+7LL; ll n,m,dp[3010][3010]; int main(){ fastio; cin >> n >> m; dp[0][0] = 1; for(int i=1;i<=3000;i++){ dp[0][i] = 1; dp[i][0] = 1; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[i][j] = dp[i-1][j]; dp[i][j] += 4*j*dp[i-1][j-1]; dp[i][j] %= mod; if(j>=2) dp[i][j] += j*(j-1)/2*dp[i-1][j-2]; dp[i][j] %= mod; if(i>=2) dp[i][j] += (i-1)*j*dp[i-2][j-1]; dp[i][j] %= mod; } } cout << dp[n][m]-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...