Submission #237852

# Submission time Handle Problem Language Result Execution time Memory
237852 2020-06-09T04:38:16 Z sahil_k Tents (JOI18_tents) C++14
0 / 100
5 ms 384 KB
#include <iostream>
#define MOD 1000000007
using namespace std;
long long dp_ind[3001][3001];
long long dp_ttl[3001][3001];
int main () {
	int n, m;
	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			dp_ind[i][j] = (4*(dp_ttl[i-1][j-1]+1))%MOD;
			dp_ind[i][j] = (dp_ind[i][j]+1ll*(dp_ttl[max(0, i-2)][j-1]+1)*(i-1))%MOD;
			dp_ind[i][j] = (dp_ind[i][j]+1ll*(dp_ttl[i-1][max(0, j-2)]+1)*(j-1))%MOD;
			dp_ttl[i][j] = (dp_ttl[i-1][j]+dp_ttl[i][j-1]-dp_ttl[i-1][j-1]+dp_ind[i][j]+MOD)%MOD;
		}
	}
	cout << dp_ttl[n][m] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -