Submission #1015052

#TimeUsernameProblemLanguageResultExecution timeMemory
1015052yellowtoadKangaroo (CEOI16_kangaroo)C++17
0 / 100
1 ms600 KiB
#include <iostream> using namespace std; const long long mod = 1e9+7; long long n, st, ed, dp[2010][2010][3]; int main() { cin >> n >> st >> ed; if ((st == 1) || (ed == 1)) dp[1][1][1] = 1; else dp[1][1][0] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 0; k < 3; k++) { if ((i == st) || (i == ed)) { if (k > 0) { if ((k < 2) || (i == n) || (j > 1)) (dp[i][j][k] += dp[i-1][j][k-1]) %= mod; (dp[i][j][k] += dp[i-1][j-1][k-1]) %= mod; } } else { (dp[i][j][k] += dp[i-1][j-1][k]*((j-1)*2-k)) %= mod; (dp[i][j][k] += dp[i-1][j+1][k]*j) %= mod; } } } } cout << dp[n][1][2] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...