# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1033907 | khanhtb | Tents (JOI18_tents) | C++14 | 105 ms | 70996 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,Ofast,unroll-loops")
// #pragma GCC targt("arch=skylake,avx2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define vi vector<ll>
#define vii vector<vi>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second
using namespace std;
const ll mod = 1e9+7;
const ll inf = 2e18;
const ll blocksz = 320;
const ll N = 3e3 + 8;
ll dp[N][N],n,m;
ll C2(ll x){
return (x*(x-1)/2)%mod;
}
void solve(){
cin >> n >> m;
for(ll j = 0; j <= m; j++) dp[0][j] = 1;
for(ll i = 1; i <= n; i++){
for(ll j = 0; j <= m; j++){
dp[i][j] = dp[i-1][j-1]*4*j%mod;
dp[i][j] = (dp[i][j]+dp[i-1][j])%mod;
if(j > 1) dp[i][j] = (dp[i][j]+dp[i-1][j-2]*C2(j)%mod)%mod;
if(i > 1) dp[i][j] = (dp[i][j]+dp[i-2][j-1]*(j*(i-1)%mod)%mod)%mod;
}
}
cout << (dp[n][m]+mod-1)%mod;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("test.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll T = 1;
// cin >> T;
for (ll i = 1; i <= T; i++){
solve();
cout << '\n';
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |