이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll MOD = 1e9+7;
int h, w;
ll dp[3010][3010];
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
#ifdef LOCAL_DEFINE
freopen("input.txt", "r", stdin);
#endif
cin >> h >> w;
for(int i = 0; i <= w; i++){
dp[0][i] = 1;
}
for(int i = 0; i <= h; i++){
dp[i][0] = 1;
}
//memset(dp, 0, sizeof dp);
for(int i = 1; i <= h; i++){
for(int j = 1; j <= w; j++){
dp[i][j] += dp[i-1][j];
dp[i][j] += 4*j*dp[i-1][j-1];
if(j>1) dp[i][j] += j*(j-1)/2*dp[i-1][j-2];
if(i>1) dp[i][j] += j*(i-1)*dp[i-2][j-1];
dp[i][j] %= MOD;
}
}
cout << dp[h][w]-1 % MOD << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |