Submission #310699

#TimeUsernameProblemLanguageResultExecution timeMemory
310699arnold518Tents (JOI18_tents)C++14
100 / 100
149 ms71032 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 3000; const ll MOD = 1e9+7; int N, M; ll dp[MAXN+10][MAXN+10]; int main() { scanf("%d%d", &N, &M); for(int i=0; i<=N; i++) dp[i][0]=1; for(int j=0; j<=M; j++) dp[0][j]=1; for(int i=1; i<=N; i++) { for(int j=1; j<=M; j++) { if(j>=2) dp[i][j]+=(ll)j*(j-1)/2*dp[i-1][j-2]%MOD; dp[i][j]+=(ll)4*j*dp[i-1][j-1]%MOD; if(i>=2) dp[i][j]+=(ll)j*(i-1)*dp[i-2][j-1]%MOD; dp[i][j]+=dp[i-1][j]; dp[i][j]%=MOD; } } printf("%lld\n", (dp[N][M]+MOD-1)%MOD); }

Compilation message (stderr)

tents.cpp: In function 'int main()':
tents.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...