# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78495 | nxteru | Tents (JOI18_tents) | C++14 | 219 ms | 71272 KiB |
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 <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000
ll h,w,dp[3005][3005],ans=-1;
int main(void){
scanf("%lld%lld",&h,&w);
dp[h][w]=1;
for(ll i=h;i>0;i--){
for(ll j=w;j>=0;j--){
if(j>=2)dp[i-1][j-2]=(dp[i-1][j-2]+dp[i][j]*(j*(j-1)/2)%M)%M;
if(j>0)dp[i-1][j-1]=(dp[i-1][j-1]+dp[i][j]*4*j%M)%M;
if(i>=2&&j>0)dp[i-2][j-1]=(dp[i-2][j-1]+dp[i][j]*(i-1)*j%M)%M;
dp[i-1][j]=(dp[i-1][j]+dp[i][j])%M;
}
}
for(int j=0;j<=w;j++)ans=(ans+dp[0][j])%M;
printf("%lld\n",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |