Submission #236914

# Submission time Handle Problem Language Result Execution time Memory
236914 2020-06-03T19:09:06 Z anubhavdhar Tents (JOI18_tents) C++14
100 / 100
260 ms 71160 KB
#include<bits/stdc++.h>

#define ll long long int
#define pb push_back
#define mp make_pair
#define FOR(i,n) for(i=0;i<(n);++i)
#define FORe(i,n) for(i=1;i<=(n);++i)
#define FORr(i,a,b) for(i=(a);i<(b);++i)
#define FORrev(i,n) for(i=(n);i>=0;--i)
#define F0R(i,n) for(int i=0;i<(n);++i)
#define F0Re(i,n) for(int i=1;i<=(n);++i)
#define F0Rr(i,a,b) for(ll i=(a);i<(b);++i)
#define F0Rrev(i,n) for(int i=(n);i>=0;--i)
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define ff first 
#define ss second
#define cd complex<double>
#define vcd vector<cd>
#define ldd long double
#define dbgLine cout<<"Line : "<<__LINE__<<'\n'
#define all(x) (x).begin(),(x).end()

using namespace std;

const short int __PRECISION = 10;

const ll MOD = 1e9+7;
const ll INF = 1e17 + 1101;
const ll LOGN = 17;
const ll MAXN = 3001;
const ll ROOTN = 320;

const ldd PI = acos(-1);
const ldd EPS = 1e-7;

ll dp[MAXN][MAXN];

#define C(a) ((a*a-a)/2)

ll DP(int i, int j)
{
	if(i < 0 or j < 0)	return 0;
	ll& t = dp[i][j];
	if(t != -1)	return t;
	t = 0;
	t += DP(i-1,j);
	t += 4*j*DP(i-1,j-1);
	t += (i-1)*j*DP(i-2,j-1);
	t += C(j)*DP(i-1,j-2);
	t %= MOD;
	//assert(t == dp[i][j]);
	return t;
}

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int i, j;
	FOR(i, MAXN)
		FOR(j, MAXN)
			dp[i][j] = (i == 0 || j == 0) ? 1 : -1;
	cin>>i>>j;
	cout<<(DP(i, j) + MOD - 1) % MOD << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 43 ms 70776 KB Output is correct
2 Correct 43 ms 70904 KB Output is correct
3 Correct 46 ms 70784 KB Output is correct
4 Correct 42 ms 70776 KB Output is correct
5 Correct 42 ms 70912 KB Output is correct
6 Correct 42 ms 70776 KB Output is correct
7 Correct 48 ms 70776 KB Output is correct
8 Correct 48 ms 70776 KB Output is correct
9 Correct 41 ms 70776 KB Output is correct
10 Correct 43 ms 70776 KB Output is correct
11 Correct 44 ms 70776 KB Output is correct
12 Correct 45 ms 70784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 70776 KB Output is correct
2 Correct 43 ms 70904 KB Output is correct
3 Correct 46 ms 70784 KB Output is correct
4 Correct 42 ms 70776 KB Output is correct
5 Correct 42 ms 70912 KB Output is correct
6 Correct 42 ms 70776 KB Output is correct
7 Correct 48 ms 70776 KB Output is correct
8 Correct 48 ms 70776 KB Output is correct
9 Correct 41 ms 70776 KB Output is correct
10 Correct 43 ms 70776 KB Output is correct
11 Correct 44 ms 70776 KB Output is correct
12 Correct 45 ms 70784 KB Output is correct
13 Correct 45 ms 70776 KB Output is correct
14 Correct 41 ms 70904 KB Output is correct
15 Correct 175 ms 70904 KB Output is correct
16 Correct 44 ms 70776 KB Output is correct
17 Correct 60 ms 70776 KB Output is correct
18 Correct 70 ms 71032 KB Output is correct
19 Correct 196 ms 70904 KB Output is correct
20 Correct 163 ms 71160 KB Output is correct
21 Correct 109 ms 70904 KB Output is correct
22 Correct 113 ms 70904 KB Output is correct
23 Correct 83 ms 70904 KB Output is correct
24 Correct 258 ms 71032 KB Output is correct
25 Correct 195 ms 71008 KB Output is correct
26 Correct 238 ms 71040 KB Output is correct
27 Correct 260 ms 71032 KB Output is correct