답안 #913949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
913949 2024-01-20T16:02:24 Z penguin133 Tents (JOI18_tents) C++17
100 / 100
197 ms 71568 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int memo[3005][3005];
const int mod = 1e9 + 7;

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

void solve(){
	int n, m; cin >> n >> m;
	memset(memo, -1, sizeof(memo));
	cout << (dp(n, m) - 1 + mod) % mod << '\n';
}

main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int tc = 1;
	//cin >> tc;
	for(int tc1=1;tc1<=tc;tc1++){
		// cout << "Case #" << tc1 << ": ";
		solve();
	}
}

Compilation message

tents.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 71004 KB Output is correct
2 Correct 12 ms 70928 KB Output is correct
3 Correct 13 ms 70904 KB Output is correct
4 Correct 13 ms 71136 KB Output is correct
5 Correct 13 ms 70920 KB Output is correct
6 Correct 12 ms 71136 KB Output is correct
7 Correct 14 ms 71000 KB Output is correct
8 Correct 12 ms 71112 KB Output is correct
9 Correct 13 ms 71004 KB Output is correct
10 Correct 13 ms 70928 KB Output is correct
11 Correct 12 ms 71004 KB Output is correct
12 Correct 15 ms 71000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 71004 KB Output is correct
2 Correct 12 ms 70928 KB Output is correct
3 Correct 13 ms 70904 KB Output is correct
4 Correct 13 ms 71136 KB Output is correct
5 Correct 13 ms 70920 KB Output is correct
6 Correct 12 ms 71136 KB Output is correct
7 Correct 14 ms 71000 KB Output is correct
8 Correct 12 ms 71112 KB Output is correct
9 Correct 13 ms 71004 KB Output is correct
10 Correct 13 ms 70928 KB Output is correct
11 Correct 12 ms 71004 KB Output is correct
12 Correct 15 ms 71000 KB Output is correct
13 Correct 13 ms 71000 KB Output is correct
14 Correct 13 ms 71260 KB Output is correct
15 Correct 120 ms 71260 KB Output is correct
16 Correct 15 ms 71000 KB Output is correct
17 Correct 24 ms 71004 KB Output is correct
18 Correct 40 ms 71000 KB Output is correct
19 Correct 163 ms 71260 KB Output is correct
20 Correct 114 ms 71260 KB Output is correct
21 Correct 72 ms 71260 KB Output is correct
22 Correct 86 ms 71456 KB Output is correct
23 Correct 57 ms 71256 KB Output is correct
24 Correct 197 ms 71356 KB Output is correct
25 Correct 137 ms 71320 KB Output is correct
26 Correct 167 ms 71568 KB Output is correct
27 Correct 176 ms 71348 KB Output is correct