This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |