# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
110848 | mosesmayer | Kangaroo (CEOI16_kangaroo) | C++17 | 82 ms | 31992 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
typedef long long LL;
const LL mod = 1e9 + 7;
int n, s, t;
LL dp[2005][2005];
LL f(int pos, int cc){
if (pos > n) return cc == 1; // base case, reached if cc = 1 when we reach end position
if (pos > 1 && cc < 1) return 0; // once pos after 1, impossible as we have at least 1 contiguous component
LL &ret = dp[pos][cc];
if (ret != -1) return ret;
ret = 0;
//special case --> endpoints
if (!(pos ^ s) || !(pos ^ t)){ // UwU ಠ_ಠ
(ret += f(pos + 1, cc)) %= mod; // already ada.
(ret += f(pos + 1, cc + 1)) %= mod; // desired endpoint not used
} else {
int ends = 2 - (pos > s) - (pos > t);
//new component --> two adjacent will be smaller
(ret += f(pos + 1, cc + 1) * (cc - 1 + ends)) %= mod; // create new component, ends == extra empty spaces due to ends
//merge component --> larger than two adjacent
(ret += f(pos + 1, cc - 1) * (cc - 1)) %= mod;
}
return ret;
}
# | 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... |