Submission #78495

#TimeUsernameProblemLanguageResultExecution timeMemory
78495nxteruTents (JOI18_tents)C++14
100 / 100
219 ms71272 KiB
#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)

tents.cpp: In function 'int main()':
tents.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&h,&w);
     ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...