Submission #740612

#TimeUsernameProblemLanguageResultExecution timeMemory
740612MladenPKangaroo (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) - (cf < i)) * 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...