답안 #77888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77888 2018-10-01T04:11:27 Z gs14004 Tents (JOI18_tents) C++17
100 / 100
311 ms 71856 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3005;
const int mod = 1e9 + 7;
typedef long long lint;

lint dp[MAXN][MAXN];

lint f(int x, int y){
	if(y < 0 || x < 0) return 0;
	if(x == 0) return 1;
	if(~dp[x][y]) return dp[x][y];
	lint ret = f(x-1, y);
	ret += f(x-1, y-2) * (y * (y - 1) / 2);
	ret += f(x-2, y-1) * y * (x - 1);
	ret += f(x-1, y-1) * 4 * y;
	return dp[x][y] = ret % mod;
}

int main(){
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	cout << (f(n, m) + mod - 1) % mod << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 71160 KB Output is correct
2 Correct 57 ms 71304 KB Output is correct
3 Correct 62 ms 71408 KB Output is correct
4 Correct 56 ms 71452 KB Output is correct
5 Correct 55 ms 71452 KB Output is correct
6 Correct 59 ms 71452 KB Output is correct
7 Correct 56 ms 71480 KB Output is correct
8 Correct 58 ms 71480 KB Output is correct
9 Correct 58 ms 71488 KB Output is correct
10 Correct 67 ms 71632 KB Output is correct
11 Correct 58 ms 71632 KB Output is correct
12 Correct 58 ms 71632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 71160 KB Output is correct
2 Correct 57 ms 71304 KB Output is correct
3 Correct 62 ms 71408 KB Output is correct
4 Correct 56 ms 71452 KB Output is correct
5 Correct 55 ms 71452 KB Output is correct
6 Correct 59 ms 71452 KB Output is correct
7 Correct 56 ms 71480 KB Output is correct
8 Correct 58 ms 71480 KB Output is correct
9 Correct 58 ms 71488 KB Output is correct
10 Correct 67 ms 71632 KB Output is correct
11 Correct 58 ms 71632 KB Output is correct
12 Correct 58 ms 71632 KB Output is correct
13 Correct 59 ms 71632 KB Output is correct
14 Correct 58 ms 71640 KB Output is correct
15 Correct 203 ms 71644 KB Output is correct
16 Correct 59 ms 71644 KB Output is correct
17 Correct 73 ms 71652 KB Output is correct
18 Correct 90 ms 71652 KB Output is correct
19 Correct 231 ms 71660 KB Output is correct
20 Correct 200 ms 71664 KB Output is correct
21 Correct 136 ms 71716 KB Output is correct
22 Correct 147 ms 71800 KB Output is correct
23 Correct 116 ms 71836 KB Output is correct
24 Correct 311 ms 71840 KB Output is correct
25 Correct 240 ms 71856 KB Output is correct
26 Correct 264 ms 71856 KB Output is correct
27 Correct 300 ms 71856 KB Output is correct