제출 #1127731

#제출 시각아이디문제언어결과실행 시간메모리
1127731Nelt캥거루 (CEOI16_kangaroo)C++20
6 / 100
0 ms464 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define endl "\n" using namespace std; using namespace __gnu_pbds; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T, typename key = less_equal<T>> using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>; const ll N = 2005, mod = 1e9 + 7; ll dp[N][N]; void solve() { ll n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; ll cur = 0; for (ll i = 2; i <= n; i++) { if (i == cs or i == cf) { for (ll j = 1; j < i; j++) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod, dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % mod; cur++; continue; } for (ll j = 1; j < i; j++) dp[i][j - 1] = (dp[i][j - 1] + dp[i - 1][j] * (j - 1)) % mod, dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j] * (j + 1 - cur)) % mod; } cout << dp[n][1] << endl; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll t = 1; // precomp(); // cin >> t; for (ll cs = 1; cs <= t; cs++) solve(); // cerr << "\nTime elapsed: " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...