제출 #1051154

#제출 시각아이디문제언어결과실행 시간메모리
1051154SulA캥거루 (CEOI16_kangaroo)C++17
100 / 100
22 ms31752 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, cs, cf; cin >> n >> cs >> cf; const int MOD = 1e9 + 7; long long dp[n+1][n+1] = {}; dp[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { if (i == cs || i == cf) { dp[i][j] = dp[i-1][j] + dp[i-1][j-1]; } else { dp[i][j] = ( dp[i-1][j-1]*(j - (cs < i) - (cf < i)) + dp[i-1][j+1]*j % MOD ) % 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...