#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_bcak
#define gcd __gcd
using namespace std;
ll n,m,k,i,j,ans,d[3100][3100],mod=1000000007;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(i=0; i<=n; i++){
for(j=0; j<=m; j++){
if(i==0 || j==0)d[i][j]=1;
else{
d[i][j]=(d[i-1][j]+d[i-1][j-1]*j*4)%mod;
if(i>1)d[i][j]=(d[i][j]+d[i-2][j-1]*j*i-d[i-2][j-1]*j)%mod;
if(j>1)d[i][j]=(d[i][j]+d[i-1][j-2]*j*(j-1)/2)%mod;
}
}
}
cout<<d[n][m]-1;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
6492 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
8540 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
8540 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
57948 KB |
Output is correct |
15 |
Correct |
47 ms |
68280 KB |
Output is correct |
16 |
Correct |
5 ms |
6492 KB |
Output is correct |
17 |
Correct |
11 ms |
19008 KB |
Output is correct |
18 |
Correct |
14 ms |
29312 KB |
Output is correct |
19 |
Correct |
54 ms |
72276 KB |
Output is correct |
20 |
Correct |
44 ms |
59996 KB |
Output is correct |
21 |
Correct |
29 ms |
41556 KB |
Output is correct |
22 |
Correct |
29 ms |
53844 KB |
Output is correct |
23 |
Correct |
21 ms |
74332 KB |
Output is correct |
24 |
Correct |
71 ms |
74328 KB |
Output is correct |
25 |
Correct |
54 ms |
64080 KB |
Output is correct |
26 |
Correct |
63 ms |
70328 KB |
Output is correct |
27 |
Correct |
70 ms |
72376 KB |
Output is correct |