이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
const ll MOD=1000000007LL;
template<typename T> void chmax(T &a,T b){a=max(a,b);}
template<typename T> void chmin(T &a,T b){a=min(a,b);}
ll dp[310][310][310];
int main(){
ll h,w;cin>>h>>w;if(h>300||w>300)return 0;
dp[0][0][w]=1;
for(ll i=1;i<=h;i++){
for(ll j=0;j<=w;j++){
for(ll k=0;k<=w;k++){
if(j<w)dp[i][j][k]+=dp[i-1][j+1][k]*(j+1LL)%MOD;
if(k<w){
dp[i][j][k]+=dp[i-1][j][k+1]*4LL%MOD*(k+1LL)%MOD;
if(j)dp[i][j][k]+=dp[i-1][j-1][k+1]*(k+1LL)%MOD;
if(k<w-1)dp[i][j][k]+=dp[i-1][j][k+2]*((k+2LL)*(k+1LL)/2LL)%MOD;
}
dp[i][j][k]+=dp[i-1][j][k];
dp[i][j][k]%=MOD;
}
}
}
ll ans=0;
for(int k=0;k<w;k++){
ans+=dp[h][0][k];
ans%=MOD;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |