# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055049 | manhlinh1501 | Tents (JOI18_tents) | C++17 | 152 ms | 71344 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 <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 3e3 + 5;
const i64 MOD = 1e9 + 7;
int N, M;
i64 dp[MAXN][MAXN];
i64 MUL(i64 a, i64 b) {
return (a * b) % MOD;
}
i64 ADD(i64 a, i64 b) {
return (a + b) % MOD;
}
i64 calc(int r, int c) {
if(r < 0 or c < 0) return 0;
if(r == 0 or c == 0) return 1;
i64 &res = dp[r][c];
if(res != -1) return res;
res = 0;
res = ADD(res, MUL(c * (c - 1) / 2, calc(r - 1, c - 2)));
res = ADD(res, calc(r - 1, c));
res = ADD(res, MUL(4 * c, calc(r - 1, c - 1)));
res = ADD(res, MUL(c * (r - 1), calc(r - 2, c - 1)));
return res;
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> M;
memset(dp, -1, sizeof dp);
cout << (calc(N, M) - 1 + MOD) % MOD;
return (0 ^ 0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |