# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44367 | choikiwon | Tents (JOI18_tents) | C++17 | 429 ms | 36324 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;
const int mod = 1e9 + 7;
int H, W;
int cc[3010][3010];
int dp(int r, int c) {
int &ret = cc[r][c];
if(ret != -1) return ret;
if(!r || !c) return ret = 1;
ret = 0;
ret += dp(r - 1, c);
ret %= mod;
if(r >= 1) {
ret += 1LL * 4 * c % mod * dp(r - 1, c - 1) % mod;
ret %= mod;
}
if(r >= 2) {
ret += 1LL * (r - 1) * c % mod * dp(r - 2, c - 1) % mod;
ret %= mod;
}
if(c >= 2) {
ret += 1LL * (c * (c - 1) / 2) * dp(r - 1, c - 2) % mod;
ret %= mod;
}
return ret;
}
int main() {
scanf("%d %d", &H, &W);
memset(cc, -1, sizeof(cc));
printf("%d", dp(H, W) - 1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |