제출 #996555

#제출 시각아이디문제언어결과실행 시간메모리
996555giorgi_pkhaladzeTents (JOI18_tents)C++14
100 / 100
71 ms74332 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...