Submission #169660

# Submission time Handle Problem Language Result Execution time Memory
169660 2019-12-21T22:21:21 Z super_j6 Tents (JOI18_tents) C++14
100 / 100
595 ms 70924 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) * (j - 4) * (j - 5) / 4 % 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;
}
# Verdict Execution time Memory 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 1144 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 4 ms 1404 KB Output is correct
7 Correct 4 ms 888 KB Output is correct
8 Correct 4 ms 1528 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 10 ms 2300 KB Output is correct
# Verdict Execution time Memory 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 1144 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 4 ms 1404 KB Output is correct
7 Correct 4 ms 888 KB Output is correct
8 Correct 4 ms 1528 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 10 ms 2300 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 13 ms 9720 KB Output is correct
15 Correct 383 ms 55160 KB Output is correct
16 Correct 27 ms 4092 KB Output is correct
17 Correct 87 ms 12924 KB Output is correct
18 Correct 109 ms 17120 KB Output is correct
19 Correct 445 ms 63068 KB Output is correct
20 Correct 356 ms 50908 KB Output is correct
21 Correct 235 ms 33784 KB Output is correct
22 Correct 234 ms 35448 KB Output is correct
23 Correct 139 ms 27000 KB Output is correct
24 Correct 595 ms 70924 KB Output is correct
25 Correct 451 ms 61304 KB Output is correct
26 Correct 514 ms 66664 KB Output is correct
27 Correct 574 ms 69060 KB Output is correct