답안 #68675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68675 2018-08-18T01:54:03 Z IvanC Tents (JOI18_tents) C++17
100 / 100
312 ms 71920 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 3010;
const int MOD = 1e9 + 7;

ll escolhe2(ll x){
	return (x * (x-1))/2;
}

ll dp[MAXN][MAXN];
int H,W;

ll solve(int a,int b){

	if(a < 0 || b < 0) return 0;
	if(a == 0 || b == 0) return 1;
	if(dp[a][b] != -1) return dp[a][b];

	ll qtd = solve(a-1,b);
	qtd += solve(a - 1,b - 2)*escolhe2(b);
	qtd += 4*solve(a-1,b-1)*b;
	qtd += solve(a - 2,b - 1)*b*(a-1);
	if(a == H && b == W) qtd--;

	qtd %= MOD;

	return dp[a][b] = qtd;

}

int main(){

	memset(dp,-1,sizeof(dp));
	cin >> H >> W;
	cout << solve(H,W) << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 71288 KB Output is correct
2 Correct 57 ms 71416 KB Output is correct
3 Correct 55 ms 71416 KB Output is correct
4 Correct 64 ms 71420 KB Output is correct
5 Correct 59 ms 71516 KB Output is correct
6 Correct 55 ms 71516 KB Output is correct
7 Correct 56 ms 71516 KB Output is correct
8 Correct 57 ms 71516 KB Output is correct
9 Correct 58 ms 71516 KB Output is correct
10 Correct 56 ms 71516 KB Output is correct
11 Correct 55 ms 71516 KB Output is correct
12 Correct 59 ms 71516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 71288 KB Output is correct
2 Correct 57 ms 71416 KB Output is correct
3 Correct 55 ms 71416 KB Output is correct
4 Correct 64 ms 71420 KB Output is correct
5 Correct 59 ms 71516 KB Output is correct
6 Correct 55 ms 71516 KB Output is correct
7 Correct 56 ms 71516 KB Output is correct
8 Correct 57 ms 71516 KB Output is correct
9 Correct 58 ms 71516 KB Output is correct
10 Correct 56 ms 71516 KB Output is correct
11 Correct 55 ms 71516 KB Output is correct
12 Correct 59 ms 71516 KB Output is correct
13 Correct 54 ms 71524 KB Output is correct
14 Correct 63 ms 71664 KB Output is correct
15 Correct 232 ms 71860 KB Output is correct
16 Correct 62 ms 71860 KB Output is correct
17 Correct 79 ms 71860 KB Output is correct
18 Correct 94 ms 71860 KB Output is correct
19 Correct 259 ms 71880 KB Output is correct
20 Correct 206 ms 71880 KB Output is correct
21 Correct 167 ms 71880 KB Output is correct
22 Correct 161 ms 71880 KB Output is correct
23 Correct 118 ms 71880 KB Output is correct
24 Correct 312 ms 71920 KB Output is correct
25 Correct 225 ms 71920 KB Output is correct
26 Correct 245 ms 71920 KB Output is correct
27 Correct 290 ms 71920 KB Output is correct