Submission #140542

# Submission time Handle Problem Language Result Execution time Memory
140542 2019-08-03T13:21:02 Z Mahmoud_Adel Tents (JOI18_tents) C++14
100 / 100
143 ms 71032 KB
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
const int N = 3005, mod = 1e9+7;
int n, m;
ll dp[N][N];
int main()
{
	cin >> n >> m;
	for(int i=0; i<N; i++) dp[i][0] = 1, dp[0][i] = 1;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			dp[i][j] = 4 * j * dp[i-1][j-1] + dp[i-1][j], dp[i][j] %= mod;
			dp[i][j] += j * (j-1)/2 * dp[i-1][j-2], dp[i][j] %= mod;
			dp[i][j] += (i-1) * j * dp[i-2][j-1], dp[i][j] %= mod;
		}
	}
	cout << dp[n][m]-1 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB Output is correct
2 Correct 11 ms 12536 KB Output is correct
3 Correct 11 ms 12536 KB Output is correct
4 Correct 11 ms 12540 KB Output is correct
5 Correct 11 ms 12664 KB Output is correct
6 Correct 11 ms 12668 KB Output is correct
7 Correct 12 ms 12664 KB Output is correct
8 Correct 11 ms 12536 KB Output is correct
9 Correct 11 ms 12536 KB Output is correct
10 Correct 12 ms 12796 KB Output is correct
11 Correct 11 ms 12536 KB Output is correct
12 Correct 12 ms 13176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12536 KB Output is correct
2 Correct 11 ms 12536 KB Output is correct
3 Correct 11 ms 12536 KB Output is correct
4 Correct 11 ms 12540 KB Output is correct
5 Correct 11 ms 12664 KB Output is correct
6 Correct 11 ms 12668 KB Output is correct
7 Correct 12 ms 12664 KB Output is correct
8 Correct 11 ms 12536 KB Output is correct
9 Correct 11 ms 12536 KB Output is correct
10 Correct 12 ms 12796 KB Output is correct
11 Correct 11 ms 12536 KB Output is correct
12 Correct 12 ms 13176 KB Output is correct
13 Correct 11 ms 12524 KB Output is correct
14 Correct 12 ms 12528 KB Output is correct
15 Correct 98 ms 56148 KB Output is correct
16 Correct 17 ms 15352 KB Output is correct
17 Correct 31 ms 22264 KB Output is correct
18 Correct 35 ms 24568 KB Output is correct
19 Correct 112 ms 63352 KB Output is correct
20 Correct 99 ms 53184 KB Output is correct
21 Correct 65 ms 39284 KB Output is correct
22 Correct 63 ms 38904 KB Output is correct
23 Correct 41 ms 27128 KB Output is correct
24 Correct 143 ms 71032 KB Output is correct
25 Correct 114 ms 62968 KB Output is correct
26 Correct 127 ms 67436 KB Output is correct
27 Correct 139 ms 69416 KB Output is correct