Submission #331391

#TimeUsernameProblemLanguageResultExecution timeMemory
331391GioChkhaidzeTents (JOI18_tents)C++14
100 / 100
319 ms70892 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N=3003; ll n,m,dp[N][N],mod=1e9+7; main () { cin>>n>>m; for (int i=0; i<=max(n,m); i++) dp[i][0]=dp[0][i]=1; for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) { if (1<=i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod; if (1<=i && 1<=j) dp[i][j]=(dp[i][j]+j*dp[i-1][j-1]*4)%mod; if (2<=i && 1<=j) dp[i][j]=(dp[i][j]+j*(i-1)*dp[i-2][j-1])%mod; if (1<=i && 2<=j) dp[i][j]=(dp[i][j]+((j-1)*j/2)*dp[i-1][j-2])%mod; } cout<<(dp[n][m]-1+mod)%mod<<"\n"; }

Compilation message (stderr)

tents.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main () {
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...