# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
370924 | mjhmjh1104 | Tents (JOI18_tents) | C++14 | 503 ms | 36076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |