Submission #82389

# Submission time Handle Problem Language Result Execution time Memory
82389 2018-10-30T11:50:13 Z Kewo Tents (JOI18_tents) C++14
100 / 100
297 ms 71496 KB
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(3e3 + 5);
const int LOG = (int)(20);
const int mod = (int)(1e9 + 7);

lli n, m, dp[N][N];

lli f(lli x, lli y)
{
	lli re = 0;
	if(x < 0 || y < 0)
		return 0;
	if(x == 0 || y == 0)
		return 1;
	if(dp[x][y] != -1)
		return dp[x][y];
	re += f(x - 1, y);
	re += f(x - 1, y - 2) * y * (y - 1) / 2;
	re += f(x - 2, y - 1) * (x - 1) * y;
	re += f(x - 1, y - 1) * 4 * y;
	return dp[x][y] = re % mod;
}

int main()
{
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n >> m;
	memset(dp, -1, sizeof dp);

	cout << f(n, m) - 1;
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 71164 KB Output is correct
2 Correct 59 ms 71164 KB Output is correct
3 Correct 60 ms 71164 KB Output is correct
4 Correct 58 ms 71280 KB Output is correct
5 Correct 60 ms 71280 KB Output is correct
6 Correct 63 ms 71280 KB Output is correct
7 Correct 60 ms 71280 KB Output is correct
8 Correct 60 ms 71280 KB Output is correct
9 Correct 62 ms 71324 KB Output is correct
10 Correct 75 ms 71324 KB Output is correct
11 Correct 60 ms 71324 KB Output is correct
12 Correct 61 ms 71324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 71164 KB Output is correct
2 Correct 59 ms 71164 KB Output is correct
3 Correct 60 ms 71164 KB Output is correct
4 Correct 58 ms 71280 KB Output is correct
5 Correct 60 ms 71280 KB Output is correct
6 Correct 63 ms 71280 KB Output is correct
7 Correct 60 ms 71280 KB Output is correct
8 Correct 60 ms 71280 KB Output is correct
9 Correct 62 ms 71324 KB Output is correct
10 Correct 75 ms 71324 KB Output is correct
11 Correct 60 ms 71324 KB Output is correct
12 Correct 61 ms 71324 KB Output is correct
13 Correct 61 ms 71324 KB Output is correct
14 Correct 58 ms 71324 KB Output is correct
15 Correct 282 ms 71396 KB Output is correct
16 Correct 62 ms 71396 KB Output is correct
17 Correct 94 ms 71396 KB Output is correct
18 Correct 94 ms 71396 KB Output is correct
19 Correct 235 ms 71420 KB Output is correct
20 Correct 178 ms 71420 KB Output is correct
21 Correct 133 ms 71420 KB Output is correct
22 Correct 145 ms 71420 KB Output is correct
23 Correct 111 ms 71420 KB Output is correct
24 Correct 297 ms 71456 KB Output is correct
25 Correct 228 ms 71496 KB Output is correct
26 Correct 250 ms 71496 KB Output is correct
27 Correct 282 ms 71496 KB Output is correct