Submission #1005205

# Submission time Handle Problem Language Result Execution time Memory
1005205 2024-06-22T08:47:44 Z milisav Kangaroo (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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -