Submission #860432

#TimeUsernameProblemLanguageResultExecution timeMemory
860432rxlfd314Tents (JOI18_tents)C++17
100 / 100
130 ms35796 KiB
#include <bits/stdc++.h> using namespace std; #define vt vector #define size(x) (int((x).size())) #define all(x) begin(x), end(x) #define REP(a, b, c, d) for (int a = (b); (d) > 0 ? a <= (c) : a >= (c); a += (d)) #define FOR(a, b, c) REP(a, b, c, 1) #define ROF(a, b, c) REP(a, b, c, -1) #define chmax(a, b) a = a > (b) ? a : (b) #define chmin(a, b) a = a < (b) ? a : (b) signed main() { #ifndef DEBUG ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif constexpr int MOD = 1e9 + 7; int N, M; cin >> N >> M; vt<vt<int>> f(N+1, vt<int>(M+1)); fill(all(f[0]), 1); FOR(i, 0, N) f[i][0] = 1; FOR(i, 1, N) FOR(j, 1, M) { f[i][j] = f[i][j-1]; (f[i][j] += 4ll * f[i-1][j-1] * i % MOD) %= MOD; if (j > 1) (f[i][j] += 1ll * f[i-1][j-2] * i % MOD * (j - 1) % MOD) %= MOD; if (i > 1) (f[i][j] += 1ll * f[i-2][j-1] * i * (i - 1) / 2 % MOD) %= MOD; } cout << (f[N][M] + MOD - 1) % MOD << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...