# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
370924 | mjhmjh1104 | Tents (JOI18_tents) | C++14 | 503 ms | 36076 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
using namespace std;
const int MOD = 1e9 + 7;
int dp[3006][3006];
int f(int x, int y) {
if (dp[x][y] + 1) return dp[x][y];
if (!x || !y) return dp[x][y] = 1;
if (x == 1) return dp[x][y] = (1 + 4LL * y % MOD + 1LL * y * (y - 1) / 2 % MOD) % MOD;
if (y == 1) return dp[x][y] = (1 + 4LL * x % MOD + 1LL * x * (x - 1) / 2 % MOD) % MOD;
return dp[x][y] = (f(x, y - 1) + 4LL * x % MOD * f(x - 1, y - 1) + 1LL * x * (y - 1) % MOD * f(x - 1, y - 2) % MOD + 1LL * x * (x - 1) / 2 % MOD * f(x - 2, y - 1) % MOD) % MOD;
}
int h, w;
int main() {
fill(dp[0], dp[3005] + 3006, -1);
scanf("%d%d", &h, &w);
printf("%d", (f(h, w) + MOD - 1) % MOD);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |