답안 #49581

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49581 2018-05-31T14:19:30 Z longcqt Tents (JOI18_tents) C++11
100 / 100
828 ms 71572 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 3e3 + 1;

typedef long long ll;

int h, w;
ll d[N][N], f[N][N];
ll base = 1e9 + 7;

ll p(int n, int m)
{
	if (n*m == 0) return 1;
	if (d[n][m] != -1) return d[n][m];
	ll res = 0;
	res = (res + 4*m*p(n - 1, m - 1)) % base;
	res = (res + p(n - 1, m)) % base;
	if (m >= 2) res = (res + m*(m - 1)/2*p(n - 1, m - 2)) % base;
	if (n >= 2) res = (res + (n - 1)*m*p(n - 2, m - 1)) % base;
	d[n][m] = res;
	return res;
}


int main()
{
	cin >> h >> w;
	memset(d, -1, sizeof(d));
	//memset(f, -1, sizeof(f));
	//cout << p(h, w) <<' ' << p1(h, w) << endl;
	cout << p(h, w) - 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 70776 KB Output is correct
2 Correct 51 ms 71004 KB Output is correct
3 Correct 60 ms 71004 KB Output is correct
4 Correct 55 ms 71004 KB Output is correct
5 Correct 52 ms 71096 KB Output is correct
6 Correct 54 ms 71096 KB Output is correct
7 Correct 52 ms 71228 KB Output is correct
8 Correct 53 ms 71228 KB Output is correct
9 Correct 52 ms 71276 KB Output is correct
10 Correct 59 ms 71276 KB Output is correct
11 Correct 51 ms 71276 KB Output is correct
12 Correct 62 ms 71276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 70776 KB Output is correct
2 Correct 51 ms 71004 KB Output is correct
3 Correct 60 ms 71004 KB Output is correct
4 Correct 55 ms 71004 KB Output is correct
5 Correct 52 ms 71096 KB Output is correct
6 Correct 54 ms 71096 KB Output is correct
7 Correct 52 ms 71228 KB Output is correct
8 Correct 53 ms 71228 KB Output is correct
9 Correct 52 ms 71276 KB Output is correct
10 Correct 59 ms 71276 KB Output is correct
11 Correct 51 ms 71276 KB Output is correct
12 Correct 62 ms 71276 KB Output is correct
13 Correct 52 ms 71276 KB Output is correct
14 Correct 52 ms 71312 KB Output is correct
15 Correct 535 ms 71396 KB Output is correct
16 Correct 57 ms 71396 KB Output is correct
17 Correct 96 ms 71396 KB Output is correct
18 Correct 158 ms 71396 KB Output is correct
19 Correct 634 ms 71460 KB Output is correct
20 Correct 515 ms 71460 KB Output is correct
21 Correct 296 ms 71472 KB Output is correct
22 Correct 338 ms 71472 KB Output is correct
23 Correct 244 ms 71480 KB Output is correct
24 Correct 828 ms 71572 KB Output is correct
25 Correct 642 ms 71572 KB Output is correct
26 Correct 690 ms 71572 KB Output is correct
27 Correct 747 ms 71572 KB Output is correct