Submission #310698

#TimeUsernameProblemLanguageResultExecution timeMemory
310698arnold518Tents (JOI18_tents)C++14
100 / 100
155 ms71040 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++)
	{
		for(int j=0; j<=M; j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=1;
				continue;
			}
			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...