제출 #913806

#제출 시각아이디문제언어결과실행 시간메모리
913806Mirali7캥거루 (CEOI16_kangaroo)C++17
6 / 100
1 ms348 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; ll ans = 0; dforn(t1, 0, 1) dforn(t2, 0, 1) { vector<ll> dp(n + 3); dp[t1 + t2] = 1; forn(i, n) { vector<ll> ndp(n + 3); dforn(j, 0, n + 2) { if (i == s) { if (t1 == 1 && j > 1) (ndp[j - 1] += dp[j]) %= mod; else if (t1 == 0 && j < n + 2) (ndp[j + 1] += dp[j]) %= mod; } else if (i == f) { if (t2 == 1 && j > 1) (ndp[j - 1] += dp[j]) %= mod; else if (t2 == 0 && j < n + 2) (ndp[j + 1] += dp[j]) %= mod; } else { if (j < n + 2) (ndp[j + 1] += dp[j] * max(0, j + 1 - t1 - t2) % mod) %= mod; if (j > 1) (ndp[j - 1] += dp[j] * max(0, j - 1 - (t1 == 1 && i < s) - (t2 == 1 && i < f)) % mod) %= mod; } } dp = ndp; } (ans += dp[1]) %= mod; } cout << ans << '\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...