Submission #963534

#TimeUsernameProblemLanguageResultExecution timeMemory
963534oblantisTents (JOI18_tents)C++17
100 / 100
210 ms58852 KiB
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
#define uid(a, b) uniform_int_distribution<int>(a, b)(mt)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 2e8+1;
const int mod = 1e9+7;
const int maxn = 3000 + 5;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
ll wt[maxn][maxn];
ll go(int n, int m){
    if(n < 0 || m < 0)return 0;
    if(n == 0)return 1;
    if(wt[n][m])return wt[n][m];
    wt[n][m] = (go(n - 1, m) + go(n - 1, m - 1) * 4 * m + go(n - 1, m - 2) * m * (m - 1) / 2 + go(n - 2, m - 1) * m * (n - 1)) % mod;
    return wt[n][m];
}
void solve() {
    int n, m;
    cin >> n >> m;
    cout << go(n, m) - 1;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int times = 1; //cin >> times;
	for(int i = 1; i <= times; i++) {
		solve();
	}
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...