제출 #1293850

#제출 시각아이디문제언어결과실행 시간메모리
1293850okahak71캥거루 (CEOI16_kangaroo)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> #define ll long long #define vec vector #define pb push_back #define pll array<ll, 2> #define all(X) X.begin(), X.end() #define allr(X) X.rbegin(), X.rend() using namespace std; const ll inf = 1e18; const ll mod = 1e9 + 7; void _(){ ll n, cs,cf; cin >> n >> cs >> cf; vec<vec<ll>>dp(n + 1, vec<ll>(n + 1, 0)); dp[1][1] = 1; ll fx = 0; for(ll i = 1; i <= n; i++){ if(i == cs or i == cf) fx++; for(ll j = 1; j < i; j++){ if(j == cs or j == cf){ (dp[i][j + 1] += dp[i - 1][j]) %= mod; (dp[i][j] += dp[i - 1][j]) %= mod; } else (dp[i][j + 1] += ((2 * j + 2 - fx) * dp[i - 1][j] * 1ll) % mod) %= mod; } } cout << dp[n][1] << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(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...