Submission #342310

#TimeUsernameProblemLanguageResultExecution timeMemory
342310bigDuckTents (JOI18_tents)C++14
0 / 100
1 ms364 KiB
#include<bits/stdc++.h> using namespace std; #define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define mp make_pair #define pb push_back #define ft first #define sc second #define ll long long #define pii pair<int, int> #define count_bits __builtin_popcount #define int ll int t, n, m, k, a[300010], q, l, r; int mod=((int)1e9)+7; int dp[3010][3010]; int32_t main(){ INIT cin>>n>>m; dp[0][0]=1; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ if( (i==1) && (j==1) ){ dp[i][j]=5; } else{ dp[i][j]=max(1ll, dp[i-1][j]+dp[i][j-1])+max(1ll, dp[i-1][j-1])*4; } if(i>=2){ dp[i][j]+=max(dp[i-2][j-1], 1ll)*(i-1); } if(j>=2){ dp[i][j]+=max(dp[i-1][j-2], 1ll)*(j-1); } dp[i][j]%=mod; //cout<<dp[i][j]<<" "; } //cout<<"\n"; } cout<<(dp[n][m]-1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...