#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll dp[3002][3002];
ll n,m;
ll solve(ll x,ll y)
{
if(x==0||y==0)return 1;
if(x<0||y<0)return 0;
if(dp[x][y]!=-1)return dp[x][y];
ll val=0;
val+=solve(x,y-1);
val+=x*4*solve(x-1,y-1);
val%=mod;
val+=x*(x-1)/2*solve(x-2,y-1);
val%=mod;
val+=x*(y-1)*solve(x-1,y-2);
val%=mod;
return dp[x][y]=val;
}
int main()
{
memset(dp,-1,sizeof(dp));
cin>>n>>m;
cout<<(solve(n,m)+mod-1)%mod<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
70892 KB |
Output is correct |
2 |
Correct |
34 ms |
70892 KB |
Output is correct |
3 |
Correct |
35 ms |
70820 KB |
Output is correct |
4 |
Correct |
34 ms |
70892 KB |
Output is correct |
5 |
Correct |
35 ms |
70892 KB |
Output is correct |
6 |
Correct |
36 ms |
70908 KB |
Output is correct |
7 |
Correct |
34 ms |
70892 KB |
Output is correct |
8 |
Correct |
38 ms |
70892 KB |
Output is correct |
9 |
Correct |
35 ms |
70892 KB |
Output is correct |
10 |
Correct |
35 ms |
70892 KB |
Output is correct |
11 |
Correct |
38 ms |
70892 KB |
Output is correct |
12 |
Correct |
36 ms |
70892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
70892 KB |
Output is correct |
2 |
Correct |
34 ms |
70892 KB |
Output is correct |
3 |
Correct |
35 ms |
70820 KB |
Output is correct |
4 |
Correct |
34 ms |
70892 KB |
Output is correct |
5 |
Correct |
35 ms |
70892 KB |
Output is correct |
6 |
Correct |
36 ms |
70908 KB |
Output is correct |
7 |
Correct |
34 ms |
70892 KB |
Output is correct |
8 |
Correct |
38 ms |
70892 KB |
Output is correct |
9 |
Correct |
35 ms |
70892 KB |
Output is correct |
10 |
Correct |
35 ms |
70892 KB |
Output is correct |
11 |
Correct |
38 ms |
70892 KB |
Output is correct |
12 |
Correct |
36 ms |
70892 KB |
Output is correct |
13 |
Correct |
34 ms |
71020 KB |
Output is correct |
14 |
Correct |
37 ms |
70892 KB |
Output is correct |
15 |
Correct |
277 ms |
71072 KB |
Output is correct |
16 |
Correct |
46 ms |
71020 KB |
Output is correct |
17 |
Correct |
86 ms |
71020 KB |
Output is correct |
18 |
Correct |
82 ms |
71020 KB |
Output is correct |
19 |
Correct |
334 ms |
71088 KB |
Output is correct |
20 |
Correct |
272 ms |
71020 KB |
Output is correct |
21 |
Correct |
193 ms |
71148 KB |
Output is correct |
22 |
Correct |
162 ms |
71020 KB |
Output is correct |
23 |
Correct |
50 ms |
70892 KB |
Output is correct |
24 |
Correct |
485 ms |
71148 KB |
Output is correct |
25 |
Correct |
372 ms |
71148 KB |
Output is correct |
26 |
Correct |
407 ms |
71020 KB |
Output is correct |
27 |
Correct |
456 ms |
71148 KB |
Output is correct |