답안 #310699

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310699 2020-10-07T16:19:29 Z arnold518 Tents (JOI18_tents) C++14
100 / 100
149 ms 71032 KB
#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

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);
      |  ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 1152 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 1 ms 1408 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 2 ms 1792 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 2176 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 5 ms 9728 KB Output is correct
15 Correct 101 ms 55160 KB Output is correct
16 Correct 7 ms 4096 KB Output is correct
17 Correct 23 ms 12928 KB Output is correct
18 Correct 38 ms 17016 KB Output is correct
19 Correct 119 ms 62968 KB Output is correct
20 Correct 94 ms 50968 KB Output is correct
21 Correct 61 ms 33784 KB Output is correct
22 Correct 62 ms 35448 KB Output is correct
23 Correct 38 ms 27128 KB Output is correct
24 Correct 149 ms 71032 KB Output is correct
25 Correct 118 ms 61304 KB Output is correct
26 Correct 131 ms 66808 KB Output is correct
27 Correct 145 ms 69244 KB Output is correct