| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1323681 | ziad3ssam10 | 캥거루 (CEOI16_kangaroo) | C++20 | 57 ms | 32476 KiB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define wady \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
void files() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
}
const int mod = 1e9 + 7;
int add(int a,int b) {
return (a + b) % mod;
}
int mul(int a,int b) {
return (a * b) % mod;
}
const int N = 2000 + 20;
int n;
int dp[N][N];
int st, en;
int rec(int idx,int comp) {
if (idx > n)return comp == 1;
int &ret = dp[idx][comp];
if (~ret)return ret;
ret = 0;
if (idx == st or idx == en) {
ret = add(rec(idx + 1, comp + 1), ret);
if (comp) ret = add(ret, rec(idx + 1, comp));
} else {
ret = add(ret, mul(rec(idx + 1, comp + 1), (comp + 1) - (idx > st) - (idx > en)));
if (comp >= 2)ret = add(ret, mul(rec(idx + 1, comp - 1), comp - 1));
}
return ret;
}
void solve(int tc) {
cin >> n;
cin >> st >> en;
memset(dp, -1, sizeof dp);
cout << rec(1, 0) << endl;
}
signed main() {
wady
// files();
int t = 1;
// cin >> t;
int tc = 1;
while (t--)
solve(tc++);
}
컴파일 시 표준 에러 (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... | ||||
