제출 #724742

#제출 시각아이디문제언어결과실행 시간메모리
724742TheSahib캥거루 (CEOI16_kangaroo)C++17
100 / 100
17 ms22884 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") #define ll long long #define oo 1e9 + 9 #define pii pair<int, int> using namespace std; const int MOD = 1e9 + 7; const int MAX = 2005; ll dp[MAX][MAX]; int main(){ int n, s, f; cin >> n >> s >> f; dp[1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= i; j++) { if(i == s || i == f){ dp[i][j] += dp[i - 1][j - 1] + dp[i - 1][j]; } else{ dp[i][j] += dp[i - 1][j + 1] * j; dp[i][j] += dp[i - 1][j - 1] * (j - (s < i) - (f < i)); } dp[i][j] %= MOD; } } cout << dp[n][1] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...