답안 #946617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
946617 2024-03-14T20:09:45 Z vjudge1 캥거루 (CEOI16_kangaroo) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

using LL = long long;
using PII = pair<int, int>;

const int N = 4000;
int dp[N][N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, cs, cf;
    cin >> n >> cs >> cf;

    dp[1][1] = 1;

    for(int i = 2; i <= n; ++i){
        for(int j = 1; j <= i; ++j){
            if(i == cs or i == cf) dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
            else {
                dp[i][j] += dp[i - 1][j + 1] * j; //merging of two component
                dp[i][j] += dp[i - 1][j - 1] * j; // start of a new component
            }
        } 
    }

    cout << dp[n][1]<<"\n";
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -