Submission #1005210

# Submission time Handle Problem Language Result Execution time Memory
1005210 2024-06-22T08:56:00 Z milisav Kangaroo (CEOI16_kangaroo) C++14
100 / 100
10 ms 16220 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;
    }
    if(cf==1 || cs==1) dp[1][0]=1;
    else 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 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 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 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 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 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 1 ms 6492 KB Output is correct
23 Correct 2 ms 6716 KB Output is correct
24 Correct 7 ms 16204 KB Output is correct
25 Correct 7 ms 16216 KB Output is correct
26 Correct 9 ms 16220 KB Output is correct
27 Correct 10 ms 15960 KB Output is correct
28 Correct 4 ms 12636 KB Output is correct