Submission #335384

#TimeUsernameProblemLanguageResultExecution timeMemory
335384mehrdad_sohrabiTents (JOI18_tents)C++14
100 / 100
312 ms73580 KiB
#include <bits/stdc++.h> typedef long long int ll; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second #define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; using namespace std; const int N=3e3+100; ll dp[N][N]; ll mod=1e9+7; int32_t main(){ ll n,m; cin >> n >> m; dp[0][0]=1; for (int i=1;i<N;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][j-1]+dp[i-1][j-1]*4*i%mod; if (i>=2) dp[i][j]+=dp[i-2][j-1]*(i*(i-1)/2)%mod; if (j>=2) dp[i][j]+=dp[i-1][j-2]*i*(j-1)%mod; dp[i][j]%=mod; } } cout << dp[n][m]-1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...