Submission #1117967

#TimeUsernameProblemLanguageResultExecution timeMemory
1117967AtabayRajabliKangaroo (CEOI16_kangaroo)C++17
6 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define all(v) v.begin(), v.end() #define int long long using namespace std; const int sz = 2e3 + 4, mod = 1e9 + 7; int n, s, f, dp[sz][sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> s >> f; int fixed = 0; dp[1][1] = 1; for(int i = 2; i <= n; i++) { if(i == s || i == f) fixed++; for(int j = 1; j <= i; j++) { if(i == s || i == f) { dp[i][j] += dp[i - 1][j - 1]; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j]; dp[i][j] %= mod; } else { dp[i][j] += dp[i - 1][j - 1] * (j - fixed) % mod; dp[i][j] %= mod; dp[i][j] += dp[i - 1][j + 1] * j % mod; dp[i][j] %= mod; } } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...