답안 #444295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
444295 2021-07-13T14:10:36 Z ajpiano 캥거루 (CEOI16_kangaroo) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second

typedef long long ll;
typedef pair<int, int> pi;

const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, cs, cf; cin >> n >> cs >> cf;
    int dp[n+1][n+1];
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            dp[i][j] = 0;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 1; j <= n-1; j++){
            if(i == cs || i == cf){
                dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
                if(dp[i][j] >= mod) dp[i][j] -= mod;
            }else{
                dp[i][j] = dp[i-1][j+1] + dp[i-1][j-1];
                dp[i][j] = (ll)dp[i][j]*(ll)j%(ll)mod;
            }
        }
    }
    cout << dp[n][1] << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct