Submission #711220

#TimeUsernameProblemLanguageResultExecution timeMemory
711220Radin_Zahedi2Tents (JOI18_tents)C++17
100 / 100
149 ms35520 KiB
#include<bits/stdc++.h> //#pragma GCC optimize("O2") using namespace std; using ll = long long; using ld = long double; #define pb push_back #define mp make_pair #define fi first #define se second #define sz(x) (int)x.size() #define endl '\n' const int mod = 1e9 + 7; const int inf = 2e9 + 5; const ll linf = 9e18 + 5; int n, m; const int N = 3e3 + 5; const int M = 3e3 + 5; int dp[N][M]; int mull(int a, int b) { return (1ll * a * b) % mod; } int c2(int n) { return (1ll * n * (n - 1)) / 2; } void init() { } void input() { cin >> n >> m; } void solve() { for (int j = 0; j <= m; j++) { dp[0][j] = 1; } for (int i = 1; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = dp[i - 1][j]; if (j >= 1) { dp[i][j] += mull(mull(j, 4), dp[i - 1][j - 1]); dp[i][j] %= mod; } if (i >= 2) { dp[i][j] += mull(mull(j, i - 1), dp[i - 2][j - 1]); dp[i][j] %= mod; } if (i >= 1 && j >= 2) { dp[i][j] += mull(c2(j), dp[i - 1][j - 2]); dp[i][j] %= mod; } } } cout << dp[n][m] - 1; } void output() { } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int number_of_testcases = 1; //cin >> number_of_testcases; while (number_of_testcases--) { init(); input(); solve(); output(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...