Submission #130549

#TimeUsernameProblemLanguageResultExecution timeMemory
130549keko37Kangaroo (CEOI16_kangaroo)C++14
6 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; typedef long long llint; const int MAXN = 5005; const int MOD = 1000000007; int n, x, y; llint dp[MAXN][MAXN]; int main () { cin >> n >> x >> y; if (x > y) swap(x, y); dp[n+1][0] = 1; for (llint i = n; i >= 1; i--) { for (llint g = 1; g <= n; g++) { if (y < i) dp[i][g] = (dp[i+1][g-1] + (g+1) * g % MOD * dp[i+1][g+1] % MOD) % MOD; if (i == y) dp[i][g] = (dp[i+1][g-1] + g * dp[i+1][g] % MOD) % MOD; if (x < i && i < y) dp[i][g] = (dp[i+1][g-1] + g * g % MOD * dp[i+1][g+1] % MOD) % MOD; if (i == x) dp[i][g] = (dp[i+1][g-1] + (g-1) * dp[i+1][g] % MOD) % MOD; if (i < x) dp[i][g] = (dp[i+1][g-1] + (g-1) * g % MOD * dp[i+1][g+1] % MOD) % MOD; } } cout << dp[2][2]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...