Submission #72457

# Submission time Handle Problem Language Result Execution time Memory
72457 2018-08-26T08:19:45 Z Vahan Tents (JOI18_tents) C++17
100 / 100
259 ms 71108 KB
#include<iostream>
using namespace std;
long long d[3002][3002], n, m;
long long mod = 1000000007;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		d[i][0] = 1;
		d[i][1] = i*(i - 1) / 2 + 4 * i + 1;
	}
	for (int i = 1; i <= m; i++)
	{
		d[0][i] = 1;
		d[1][i] = (i*(i - 1) / 2 + 4 * i + 1) % mod;
	}
	for (long long i = 2; i <= n; i++)
	{
		for (long long j = 2; j <= m; j++)
		{
			d[i][j] = ((i*(i - 1) / 2) * d[i - 2][j - 1] + i * 4 * d[i - 1][j - 1] + i*(j - 1)*d[i - 1][j - 2] + d[i][j - 1]) % mod;
		}
	}
	cout << (d[n][m] - 1 + mod) % mod << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 3 ms 1364 KB Output is correct
5 Correct 3 ms 1364 KB Output is correct
6 Correct 3 ms 1612 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 3 ms 1644 KB Output is correct
9 Correct 3 ms 1644 KB Output is correct
10 Correct 4 ms 2040 KB Output is correct
11 Correct 2 ms 2040 KB Output is correct
12 Correct 5 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 3 ms 1364 KB Output is correct
5 Correct 3 ms 1364 KB Output is correct
6 Correct 3 ms 1612 KB Output is correct
7 Correct 3 ms 1612 KB Output is correct
8 Correct 3 ms 1644 KB Output is correct
9 Correct 3 ms 1644 KB Output is correct
10 Correct 4 ms 2040 KB Output is correct
11 Correct 2 ms 2040 KB Output is correct
12 Correct 5 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 9 ms 9964 KB Output is correct
15 Correct 174 ms 55464 KB Output is correct
16 Correct 13 ms 55464 KB Output is correct
17 Correct 39 ms 55464 KB Output is correct
18 Correct 48 ms 55464 KB Output is correct
19 Correct 195 ms 63296 KB Output is correct
20 Correct 157 ms 63296 KB Output is correct
21 Correct 104 ms 63296 KB Output is correct
22 Correct 100 ms 63296 KB Output is correct
23 Correct 64 ms 63296 KB Output is correct
24 Correct 259 ms 71108 KB Output is correct
25 Correct 196 ms 71108 KB Output is correct
26 Correct 219 ms 71108 KB Output is correct
27 Correct 247 ms 71108 KB Output is correct