Submission #1118224

#TimeUsernameProblemLanguageResultExecution timeMemory
1118224vjudge1Kangaroo (CEOI16_kangaroo)C++17
6 / 100
1 ms2556 KiB
#include <bits/stdc++.h> using namespace std; # define int long long int dp[1000][1000]; void solve() { int n, cf, cn, cnt = 0; cin >> n >> cf >> cn; dp[1][1] = 1; for(int i = 1; i <= n; i++) { if(i == cf || i == cn) cnt++; for(int j = 1; j < i; j++) { if(i == cf || i == cn) { dp[i][j] += dp[i - 1][j]; dp[i][j + 1] += dp[i - 1][j]; } else { dp[i][j + 1] += dp[i - 1][j] * (j + 1 - cnt); dp[i][j - 1] += dp[i - 1][j] * (j - 1); } } } cout << dp[n][1] << endl; } signed main() { int tt = 1; // cin >> tt; while(tt--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...