Submission #169657

# Submission time Handle Problem Language Result Execution time Memory
169657 2019-12-21T22:10:04 Z super_j6 Tents (JOI18_tents) C++14
0 / 100
3 ms 1148 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(int i = 4; i < n; i++){
		for(int 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];
			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 1148 KB Output is correct
5 Incorrect 3 ms 760 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 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 1148 KB Output is correct
5 Incorrect 3 ms 760 KB Output isn't correct
6 Halted 0 ms 0 KB -