답안 #67080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67080 2018-08-13T10:05:00 Z Diuven Tents (JOI18_tents) C++11
100 / 100
312 ms 36628 KB
#include <iostream>
using namespace std;
typedef long long ll;

const int MX=3010, MOD=1e9+7;

int h, w, D[MX][MX];

int d(int x, int y){
	int &res=D[x][y];
	if(res>=0) return res;
	res=d(x-1,y);
	res=(res+4LL*d(x-1,y-1)*y)%MOD;
	if(y>=2) res=(res+1LL*d(x-1,y-2)*(y*(y-1)/2))%MOD;
	if(x>=2) res=(res+1LL*d(x-2,y-1)*y*(x-1))%MOD;
	return res;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w;

	for(int i=1; i<=h; i++) for(int j=1; j<=w; j++) D[i][j]=-1;
	for(int i=0; i<=h; i++) D[i][0]=1;
	for(int j=1; j<=w; j++) D[0][j]=1;

	cout<<(d(h,w)+MOD-1)%MOD<<'\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 3 ms 400 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 4 ms 1348 KB Output is correct
5 Correct 3 ms 1348 KB Output is correct
6 Correct 4 ms 1592 KB Output is correct
7 Correct 3 ms 1592 KB Output is correct
8 Correct 4 ms 1724 KB Output is correct
9 Correct 3 ms 1724 KB Output is correct
10 Correct 5 ms 2028 KB Output is correct
11 Correct 3 ms 2028 KB Output is correct
12 Correct 6 ms 2216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 400 KB Output is correct
2 Correct 3 ms 400 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 4 ms 1348 KB Output is correct
5 Correct 3 ms 1348 KB Output is correct
6 Correct 4 ms 1592 KB Output is correct
7 Correct 3 ms 1592 KB Output is correct
8 Correct 4 ms 1724 KB Output is correct
9 Correct 3 ms 1724 KB Output is correct
10 Correct 5 ms 2028 KB Output is correct
11 Correct 3 ms 2028 KB Output is correct
12 Correct 6 ms 2216 KB Output is correct
13 Correct 2 ms 2216 KB Output is correct
14 Correct 8 ms 10172 KB Output is correct
15 Correct 205 ms 33460 KB Output is correct
16 Correct 5 ms 33460 KB Output is correct
17 Correct 29 ms 33460 KB Output is correct
18 Correct 58 ms 33460 KB Output is correct
19 Correct 275 ms 35396 KB Output is correct
20 Correct 204 ms 35396 KB Output is correct
21 Correct 106 ms 35396 KB Output is correct
22 Correct 112 ms 35396 KB Output is correct
23 Correct 83 ms 35396 KB Output is correct
24 Correct 283 ms 36628 KB Output is correct
25 Correct 207 ms 36628 KB Output is correct
26 Correct 264 ms 36628 KB Output is correct
27 Correct 312 ms 36628 KB Output is correct