제출 #913820

#제출 시각아이디문제언어결과실행 시간메모리
913820Mirali7캥거루 (CEOI16_kangaroo)C++17
100 / 100
31 ms620 KiB
//#include <udacha> #include <iostream> #include <string> #include <deque> #include <vector> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <queue> #include <fstream> #include <stack> #include <cmath> #include <bitset> #include <unordered_set> #include <unordered_map> #include <random> #include <array> #include <chrono> #include <functional> #include <numeric> #include <complex> using namespace std; #define ll long long #define ld long double #define ull uint64_t #define pll pair<ll, ll> #define pii pair<int, int> #define pli pair<ll, int> #define plli pair<pll, int> #define pld pair<ld, ld> #define fst first #define snd second #define pdi pair<ld, int> #define pdd pair<double, double> #define piii pair<int, pii> #define forn(i, n) for (int i = 1; i <= n; i++) #define dforn(i, a, b) for (int i = a; i <= b; i++) #define rforn(i, n) for (int i = n; i >= 1; i--) #define rdforn(i, a, b) for (int i = b; i >= a; i--) #define sforn(i, a, b, s) for (ll i = a; i <= b; i += s) #define aforn(v, a) for (auto& v : a) #define sz(a) ((int)a.size()) const int mod = 1e9 + 7; const ld pi = acos(-1); const ll N = 2e5 + 1; const ll inf = 3e18; const int iinf = 1e9; const ld dinf = 1e16; const double eps = 1e-9; void solve() { int n, s, f; cin >> n >> s >> f; vector<ll> dp(n + 1); dp[0] = 1; forn(i, n) { vector<ll> ndp(n + 1); dforn(j, 0, n) { if (i == s) { if (j) (ndp[j] += dp[j]) %= mod; if (j < n) (ndp[j + 1] += dp[j]) %= mod; } else if (i == f) { if (j) (ndp[j] += dp[j]) %= mod; if (j < n) (ndp[j + 1] += dp[j]) %= mod; } else { if (j > 1) (ndp[j - 1] += dp[j] * (j - 1) % mod) %= mod; if (j < n) (ndp[j + 1] += dp[j] * max(0, j + 1 - (i > s) - (i > f)) % mod) %= mod; } } dp = ndp; } cout << dp[1] << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) solve(); return 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...