# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1264369 | duyanhloveav | 캥거루 (CEOI16_kangaroo) | C++20 | 16 ms | 15944 KiB |
#include <bits/stdc++.h>
using namespace std;
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1LL)
using ll = long long;
const int mxn = 9 + 1e6;
const int inf = 0x3f3f3f3f;
const ll lnf = 0x3f3f3f3f3f3f3f3f;
void _27augain(void) {
int n, cs, cf;
cin >> n >> cs >> cf;
vector<vector<int>> dp(n + 2, vector<int>(n + 2));
dp[0][0] = 1;
const int mod = 7 + 1e9;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= i; ++j) {
if (i == cs || i == cf) {
(dp[i][j] += dp[i - 1][j - 1] + dp[i - 1][j]) %= mod;
} else {
(dp[i][j] += 1LL * dp[i - 1][j - 1] * (j - (i > cs) - (i > cf)) % mod + 1LL * dp[i - 1][j + 1] * j % mod) %= mod;
}
}
}
cout << dp[n][1] << "\n";
}
int32_t main(void) {
#define task "27augain"
cin.tie(0)->sync_with_stdio(0);
for (string iext : {"in", "inp"}) {
if (fopen((task "." + iext).c_str(), "r")) {
freopen((task "." + iext).c_str(), "r", stdin);
freopen(task ".out", "w", stdout);
}
}
int testcase = 1;
// cin >> testcase;
while (testcase--) {
_27augain();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |