Submission #1118230

#TimeUsernameProblemLanguageResultExecution timeMemory
1118230vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
16 ms31584 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define FORI(i, n) for(ll i = 0; i < n; i++) #define FOR(i, n) for(ll i = 1; i <= n; i++) typedef vector<ll> vl; typedef set<ll> setl; #define ff first #define ss second #define all(v) v.begin(), v.end() #define pll pair<ll, ll> #define db double #define nll cout << "\n" #define nl "\n" #define sync ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); const ll mod = 1e9 + 7; const int MAX = 2000 + 5; ll n, m, k, res; ll dp[MAX][MAX]; void solve(){ cin >> n >> m >> k; dp[1][1] = 1; for(ll i = 2; i <= n; i++){ FOR(j, i){ if(i == m|| i == k){ dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; } else{ dp[i][j] = ((dp[i - 1][j - 1] * (j - (i > m) - (i > k)) ) % mod + (dp[i - 1][j + 1] * j) % mod) % mod; } } } cout << dp[n][1] % mod; } signed main(){ // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); sync; ll t = 1; // cin >> t; FOR(i, t){ // cout << "Case #" << i << ": "; 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...