# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
109085 | DystoriaX | 캥거루 (CEOI16_kangaroo) | C++14 | 187 ms | 47600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, cs, cf;
int dp[2010][2010][3];
const int MOD = 1e9 + 7;
int add(long long a, long long b){
return (a + b) % MOD;
}
int mul(long long a, long long b){
return (a * b) % MOD;
}
int main(){
scanf("%d%d%d", &n, &cs, &cf);
dp[0][0][0] = 1;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n; j++){
for(int k = 0; k <= 2; k++){
if(k > j) continue;
int v = dp[i - 1][j][k];
if(i != cf && i != cs){
dp[i][j - 1][k] = add(dp[i][j - 1][k], mul(v, j - 1));
dp[i][j + 1][k] = add(dp[i][j + 1][k], mul(v, j + 1 - k));
} else if (k < 2) {
dp[i][j][k + 1] = add(dp[i][j][k + 1], v);
dp[i][j + 1][k + 1] = add(dp[i][j + 1][k + 1], v);
}
}
}
}
printf("%d\n", dp[n][1][2]);
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... |