Submission #1118225

#TimeUsernameProblemLanguageResultExecution timeMemory
1118225vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
17 ms31824 KiB
// #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vl vector<ll> #define vii vector<pii> #define db long double #define vll vector<pll> #define endl '\n' #define all(x) x.begin(), x.end() #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define int long long const int sz = 2e3 + 5; const int mod = 1e9 + 7; int n, cs, cf, dp[sz][sz]; void fmain(){ cin >> n >> cs >> cf; dp[1][1] = 1; for(int i = 2; i <= n; i++){ for(int j = 1; j <= n; j++){ if(i == cs or i == cf){ dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; continue; } dp[i][j] = (dp[i - 1][j - 1] * (j - (i > cs) - (i > cf)) + dp[i - 1][j + 1] * j) % mod; } } cout << dp[n][1]; } signed main(){ int tmr = 1; // cin >> tmr; while(tmr--){ fmain(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...