Submission #258090

#TimeUsernameProblemLanguageResultExecution timeMemory
258090YJUTents (JOI18_tents)C++14
100 / 100
159 ms70904 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; const ll N=3e3+5; const ll M=1e4+5; const ll MOD=1e9+7; const ld pi=acos(-1); const ll MOD2=998244353; const ll INF=(1LL<<60); #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define lwb lower_bound #define SZ(a) (ll)a.size() ll n,m,dp[N][N]; ll C(ll k){ if(k<2)return 0; return (k*(k-1)%MOD)*((MOD+1)/2)%MOD; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>m; REP(i,n+1)dp[i][0]=1;REP(i,m+1)dp[0][i]=1; REP1(i,n){ REP1(j,m){ dp[i][j]+=dp[i-1][j]; dp[i][j]+=dp[i-1][j-1]*j%MOD*4%MOD; if(j>=2)dp[i][j]+=dp[i-1][j-2]*(C(j))%MOD; if(i>=2)dp[i][j]+=dp[i-2][j-1]*(i-1)%MOD*j%MOD; dp[i][j]%=MOD; } } cout<<(dp[n][m]+MOD-1)%MOD<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...