Submission #1003280

#TimeUsernameProblemLanguageResultExecution timeMemory
1003280SharkyKangaroo (CEOI16_kangaroo)C++17
0 / 100
0 ms444 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1000000007; const int N = 2008; int dp[N][N]; int32_t main() { int n, s, e, ep = 0; cin >> n >> s >> e; dp[1][1] = 1; if (s == 1 || e == 1) ep++; for (int i = 2; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == s || i == e) { ep++; dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; } else { dp[i][j] = (dp[i - 1][j - 1] * max(0LL, (j - ep)) % mod + dp[i - 1][j + 1] * j % mod) % mod; } // cout << i << ' ' << j << ' ' << dp[i][j] << '\n'; } } cout << dp[n][1] << '\n'; } // 1 5 2 4 3 6 // 1 3 2 5 4 6 // 1 4 2 5 3 6 // 1 5 3 4 2 6 // 1 4 3 5 2 6 // 6 // 4 1 3 2 6 5 // 4 2 3 1 6 5 // 4 6 1 3 2 5 // 4 6 2 3 1 5
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...