제출 #740611

#제출 시각아이디문제언어결과실행 시간메모리
740611MladenP캥거루 (CEOI16_kangaroo)C++17
0 / 100
0 ms340 KiB
#include <iostream> #define MAXN 2010 #define MOD 1000000007 using namespace std; long long dp[MAXN][MAXN]; int main() { ios::sync_with_stdio(false); cin.tie(0); long long n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; for (int i = 2; i <= n; i++) { for (long long j = 1; j <= i; j++) { if (i == cs || i == cf) { dp[i][j] = dp[i-1][j-1] + dp[i-1][j]; if (dp[i][j] >= MOD) dp[i][j] %= MOD; } else { dp[i][j] = j * dp[i-1][j+1]; dp[i][j] += (j+1 - (cs < i) - (cs < j)) * dp[i-1][j-1]; if (dp[i][j] >= MOD) dp[i][j] %= MOD; } } } cout << dp[n][1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...