Submission #657465

#TimeUsernameProblemLanguageResultExecution timeMemory
657465GusterGoose27Kangaroo (CEOI16_kangaroo)C++11
100 / 100
9 ms12244 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1e9+7; const int MAXN = 2001; int dp[MAXN][MAXN]; int n, a, b; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; a--; b--; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 1; j <= min(i+1, n-i); j++) { if (i == a || i == b) { dp[i+1][j] = dp[i][j]+dp[i][j-1]; dp[i+1][j] %= MOD; } else { dp[i+1][j] = ((ll) (j-(i >= a)-(i >= b))*dp[i][j-1]+(ll)j*dp[i][j+1]) % 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...