| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 472000 | DEQK | 캥거루 (CEOI16_kangaroo) | C++17 | 27 ms | 14252 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
const int mod = 1e9 + 7;
int n, a, b;
int dp[N][N];
void inc(int &x,int y) {
x += y;
if(x >= mod) x -= mod;
}
int main() {
scanf("%d%d%d", &n, &a, &b);
dp[1][1] = 1;
for(int i = 1; i < n; i++) {
for(int j = 1; j <= i; j++) {
if(dp[i][j] == 0) continue; // doesnt contribute to answer
if(i + 1 == a || i + 1 == b) {
inc(dp[i + 1][j], dp[i][j]);
inc(dp[i + 1][j + 1], dp[i][j]);
} else {
inc(dp[i + 1][j - 1], dp[i][j] * 1ll * (j - 1) % mod);
inc(dp[i + 1][j + 1], dp[i][j] * 1ll * (j + 1 - (i + 1 > a) - (i + 1 > b)) % mod); // can not be to the left a and to the right b
}
}
}
printf("%d", dp[n][1]);
}
컴파일 시 표준 에러 (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... | ||||
