# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1033964 | cowwycow | Tents (JOI18_tents) | C++14 | 116 ms | 70912 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.
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pll = pair<ll, ll>;
using ld = long double;
void file(){
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
}
const int maxn = 3e3 + 5;
const ll mod = 1e9 + 7;
ll dp[maxn][maxn];
void solve (){
int n, m;
cin >> n >> m;
for(int i = 0; i < maxn; i++){
dp[0][i] = 1;
dp[i][0] = 1;
}
for(ll i = 1; i <= n; i++){
for(ll j = 1; j <= m; j++){
dp[i][j] += dp[i - 1][j];
dp[i][j] += dp[i - 1][j - 1] * 4 * j % mod;
if(j >= 2) dp[i][j] += dp[i - 1][j - 2] * (j * (j - 1) / 2 % mod) % mod;
if(i >= 2) dp[i][j] += j * (i - 1) % mod * dp[i - 2][j - 1] % mod;
dp[i][j] %= mod;
}
}
dp[n][m]--;
if(dp[n][m] < 0) dp[n][m] += mod;
cout << dp[n][m];
}
int main(){
file();
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |