답안 #163881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
163881 2019-11-15T23:36:22 Z arnold518 Tents (JOI18_tents) C++14
100 / 100
86 ms 71004 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 H, W;
ll dp[MAXN+10][MAXN+10];

int main()
{
	int i, j;
	scanf("%d%d", &H, &W);

	for(i=0; i<=H; i++) dp[i][0]=1;
	for(i=0; i<=W; i++) dp[0][i]=1;

	for(i=0; i<=H; i++) dp[i][1]=(ll)i*(i-1)/2+4*i+1, dp[i][1]%=MOD;
	for(i=0; i<=W; i++) dp[1][i]=(ll)i*(i-1)/2+4*i+1, dp[1][i]%=MOD;

	for(i=2; i<=H; i++)
	{
		for(j=2; j<=W; j++)
		{
			dp[i][j]=dp[i-1][j]+(ll)j*(j-1)/2*dp[i-1][j-2]+(ll)(i-1)*j*dp[i-2][j-1]+(ll)4*j*dp[i-1][j-1];
			dp[i][j]%=MOD;
		}
	}
	dp[H][W]+=MOD-1;
	dp[H][W]%=MOD;
	printf("%lld", dp[H][W]);
}

Compilation message

tents.cpp: In function 'int main()':
tents.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &H, &W);
  ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 3 ms 1400 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 3 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 2 ms 632 KB Output is correct
6 Correct 3 ms 1400 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 3 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 2168 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 9 ms 9720 KB Output is correct
15 Correct 64 ms 55160 KB Output is correct
16 Correct 6 ms 4088 KB Output is correct
17 Correct 16 ms 12792 KB Output is correct
18 Correct 20 ms 17016 KB Output is correct
19 Correct 73 ms 63024 KB Output is correct
20 Correct 59 ms 50856 KB Output is correct
21 Correct 38 ms 33784 KB Output is correct
22 Correct 40 ms 35400 KB Output is correct
23 Correct 29 ms 27068 KB Output is correct
24 Correct 86 ms 71004 KB Output is correct
25 Correct 70 ms 61304 KB Output is correct
26 Correct 77 ms 66808 KB Output is correct
27 Correct 82 ms 69112 KB Output is correct