답안 #1005205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005205 2024-06-22T08:47:44 Z milisav 캥거루 (CEOI16_kangaroo) C++14
6 / 100
0 ms 2396 KB
#include <bits/stdc++.h>
#define maxn 2024
using namespace std;
const int mod = 1000000007;
int n, cs, cf;
int dp[maxn][maxn];
int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin>>n>>cs>>cf;
    if(n==2) {
        cout<<1<<endl;
        return 0;
    }
    dp[1][1] = 1;
    for(int i=2;i<=n;i++) {
        for(long long g=0;g<=i;g++) {
            if(i<cs && i<cf) {
                dp[i][g] = ((g?dp[i-1][g-1]:0) + g*(g+1)*dp[i-1][g+1])%mod;
                continue;
            }
            if(i==cs || i==cf) {
                dp[i][g] = (dp[i-1][g] + (g+1)*dp[i-1][g+1])%mod;
                continue;
            }
            if(i>cf && i>cs) {
                dp[i][g] = ((g?dp[i-1][g-1]:0) + (g+2)*(g+1)*dp[i-1][g+1])%mod;
                continue;
            }
            else {
                dp[i][g] = ((g?dp[i-1][g-1]:0) + (g+1)*(g+1)*dp[i-1][g+1])%mod;
                continue;
            }
        }
    }
    cout<<dp[n-1][0]<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -