# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
43966 | model_code | Tents (JOI18_tents) | C++17 | 119 ms | 71204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<algorithm>
using namespace std;
const long long mod = 1000000007;
const int MAX_N = 3000;
long long dp[MAX_N + 1][MAX_N + 1];
int H, W;
long long C2(int x){
return x * (x - 1) / 2;
}
long long solve(){
for(int i = 0; i <= H; ++i){
for(int j = 0; j <= W; ++j){
if(i == 0 || j == 0){
dp[i][j] = 1;
}else{
dp[i][j] = 0;
dp[i][j] += dp[i][j - 1];
dp[i][j] += 4ll * i * dp[i - 1][j - 1];
if(i >= 2){
long long tmp = C2(i);
dp[i][j] += tmp * dp[i - 2][j - 1];
}
if(j >= 2){
dp[i][j] += (long long)i * (j - 1) * dp[i - 1][j - 2];
}
dp[i][j] %= mod;
}
}
}
long long ans = dp[H][W] - 1;
ans %= mod;
ans += mod;
ans %= mod;
return ans;
}
int main(){
scanf("%d%d", &H, &W);
long long ans = solve();
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |