제출 #461335

#제출 시각아이디문제언어결과실행 시간메모리
461335izhang05캥거루 (CEOI16_kangaroo)C++17
100 / 100
38 ms31684 KiB
#include <bits/stdc++.h> using namespace std; //#define DEBUG void setIO(const string &name) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.exceptions(istream::failbit); #ifdef LOCAL freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); freopen((name + ".out").c_str(), "w", stderr); #endif } const int inf = 0x3f3f3f3f, mod = 1e9 + 7, maxn = 2005; const long long INFL = 0x3f3f3f3f3f3f3f3f; long long dp[maxn][maxn]; int main() { setIO("1"); int n, start, end; cin >> n >> start >> end; dp[1][1] = 1; for (int i = 2; i <= n; ++i) { for (int j = 1; j <= n; ++j) { long long &cur = dp[i][j]; if (i == start || i == end) { cur = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod; } else { cur += j * dp[i - 1][j + 1]; cur %= mod; cur += (j - (i > start) - (i > end)) * dp[i - 1][j - 1]; cur %= mod; } } } cout << dp[n][1] << "\n"; 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...