제출 #1117964

#제출 시각아이디문제언어결과실행 시간메모리
1117964AtabayRajabli캥거루 (CEOI16_kangaroo)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 2e3 + 4, mod = 1e9 + 7; int n, s, f, dp[sz][sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s >> f; int fixed = 0; dp[1][1] = 1; for(int i = 2; i <= n; i++) { if(i == s || i == f) fixed++; for(int j = 1; j <= i; j++) { if(i == s || i == f) { dp[i][j] += dp[i - 1][j - 1]; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j]; dp[i][j] %= mod; } else { dp[i][j] += dp[i - 1][j - 1] * (j - fixed) % mod; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j] * (2 * j - fixed) % mod; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j + 1] * j % mod; dp[i][j] %= mod; } } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...