# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
952910 | bananade | Tents (JOI18_tents) | C++17 | 266 ms | 70796 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;
#define int long long
int dp[3005][3005];
int h, w;
int mod = 1000000007;
int pang(int a) {
int jum = 1;
int now = 1e9 + 6;
vector<int> v;
while(now > 0) {
if(now % 2 == 1) {
v.push_back(1);
now--;
} else {
v.push_back(2);
now /= 2;
}
}
}
signed main() {
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin >> h >> w;
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] = dp[i - 1][j] + (dp[i - 1][j - 1] * j * 4);
dp[i][j] %= mod;
if(i >= 2) {
int a = dp[i - 2][j - 1] * (i - 1) * j;
a %= mod;
dp[i][j] += a;
dp[i][j] %= mod;
}
if(j >= 2) {
int a = dp[i - 1][j - 2] * (j - 1) * j / 2;
a %= mod;
dp[i][j] += a;
dp[i][j] %= mod;
}
}
//cout << i << " " << j << " " << dp[i][j] << "\n";
}
}
cout << dp[h][w] - 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |