답안 #169659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169659 2019-12-21T22:16:57 Z super_j6 Tents (JOI18_tents) C++14
100 / 100
592 ms 70904 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const long long mod = 1000000007;
const int maxn = 3004;
int n, m;
long long dp[maxn][maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	n += 4, m += 4;
	
	for(long long i = 4; i < n; i++){
		for(long long j = 4; j < m; j++){
			dp[i][j] += 4 * (dp[i - 1][j - 1] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += (j - 4) * (dp[i - 1][j - 2] + 1) % mod + (i - 4) * (dp[i - 2][j - 1] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += 16 * (i - 4) * (j - 4) % mod * (dp[i - 2][j - 2] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += 6 * (i - 4) * (i - 5) * (j - 4) % mod * (dp[i - 3][j - 2] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += 6 * (i - 4) * (j - 4) * (j - 5) % mod * (dp[i - 2][j - 3] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += 5 * (i - 4) * (i - 5) / 2 % mod * (j - 4) * (j - 5) / 2 % mod * (dp[i - 3][j - 3] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += (i - 4) * (i - 5) * (i - 6) * (j - 4) / 2 % mod * (dp[i - 4][j - 2] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += (i - 4) * (j - 4) * (j - 5) * (j - 6) / 2 % mod * (dp[i - 2][j - 4] + 1) % mod;
			dp[i][j] %= mod;
			
			dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod;
			dp[i][j] %= mod;
			
			//cout << (i - 2) << " " << (j - 2) << ": " << dp[i][j] << endl;
		}
	}
	
	cout << dp[n - 1][m - 1] << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 1272 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 4 ms 888 KB Output is correct
8 Correct 4 ms 1400 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 6 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 9 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 3 ms 1272 KB Output is correct
5 Correct 3 ms 764 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 4 ms 888 KB Output is correct
8 Correct 4 ms 1400 KB Output is correct
9 Correct 2 ms 888 KB Output is correct
10 Correct 6 ms 1784 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 9 ms 2296 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 13 ms 9720 KB Output is correct
15 Correct 381 ms 55216 KB Output is correct
16 Correct 28 ms 4088 KB Output is correct
17 Correct 89 ms 12920 KB Output is correct
18 Correct 110 ms 17108 KB Output is correct
19 Correct 445 ms 63096 KB Output is correct
20 Correct 356 ms 51056 KB Output is correct
21 Correct 234 ms 33808 KB Output is correct
22 Correct 232 ms 35576 KB Output is correct
23 Correct 138 ms 27012 KB Output is correct
24 Correct 592 ms 70904 KB Output is correct
25 Correct 448 ms 61300 KB Output is correct
26 Correct 509 ms 66688 KB Output is correct
27 Correct 568 ms 69148 KB Output is correct