Submission #1077639

#TimeUsernameProblemLanguageResultExecution timeMemory
1077639kchu_zTents (JOI18_tents)C++17
100 / 100
192 ms67668 KiB
#include <bits/stdc++.h> using namespace std; long long dp[3001][3001]; bool visited[3001][3001]; long long MOD = 1e9 + 7; long long f(int n, int m) { if (n < 0 || m < 0) return 0; if (n == 0 || m == 0) return 1; if (visited[n][m]) return dp[n][m]; visited[n][m] = 1; return dp[n][m] = (f(n - 1, m) + 4 * m * f(n - 1, m - 1) + f(n - 1, m - 2) * m * (m - 1) / 2 + f(n - 2, m - 1) * m * (n - 1)) % MOD; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; cout << (f(n, m) - 1 + MOD) % MOD << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...