# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
237773 | sahil_k | Tents (JOI18_tents) | C++14 | 5 ms | 384 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 <iostream>
#define MOD 1000000007
using namespace std;
int dp_ind[3001][3001];
int dp_ttl[3001][3001];
int dp_se[3001][3001];
int main () {
int n, m;
cin >> n >> m;
int row;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++) {
dp_se[i][j] = (dp_ttl[i-1][j-1]+1)%MOD;
dp_ind[i][j] = (4ll*dp_se[i][j])%MOD;
for (int k=0; k<i; k++) {
dp_ind[i][j] = (1ll*dp_ind[i][j]+1ll*dp_se[k][j]*(dp_ttl[i-k-1][j-1]+1))%MOD;
}
for (int k=0; k<j; k++) {
dp_ind[i][j] = (1ll*dp_ind[i][j]+1ll*dp_se[i][k]*(dp_ttl[i-1][j-k-1]+1))%MOD;
}
dp_ttl[i][j] = (1ll*dp_ttl[i-1][j]+dp_ttl[i][j-1]-dp_ttl[i-1][j-1]+dp_ind[i][j]+MOD)%MOD;
}
}
cout << dp_ttl[n][m] << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |