제출 #538370

#제출 시각아이디문제언어결과실행 시간메모리
538370alextodoran캥거루 (CEOI16_kangaroo)C++17
100 / 100
27 ms15948 KiB
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 2000; const int MOD = (int) 1e9 + 7; int N, L, R; int dp[N_MAX + 2][N_MAX + 2]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N >> L >> R; dp[0][1] = 1; for (int i = 1; i <= N; i++) { for (int open = 0; open <= N; open++) { if (i == L || i == R) { dp[i][open] += dp[i - 1][open]; if (dp[i][open] >= MOD) { dp[i][open] -= MOD; } dp[i][open - 1] += dp[i - 1][open]; if (dp[i][open - 1] >= MOD) { dp[i][open - 1] -= MOD; } } else { dp[i][open + 1] = (dp[i][open + 1] + (ll) dp[i - 1][open] * open) % MOD; dp[i][open - 1] = (dp[i][open - 1] + (ll) dp[i - 1][open] * max(0, open - (i < L) - (i < R))) % MOD; } } } cout << dp[N][0] << "\n"; 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...