Submission #242899

# Submission time Handle Problem Language Result Execution time Memory
242899 2020-06-29T17:12:25 Z abacaba Kangaroo (CEOI16_kangaroo) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e3 + 15;
int n, s, t;
int dp[N][N];

inline int add(int a, int b) {
    a += b;
    if(a >= mod)
        a -= mod;
    if(a < 0)
        a += mod;
    return a;
}

inline void add_t(int &a, int b) {
    a = add(a, b);
}

inline int mt(int a, int b) {
    return 1ll * a * b % mod;
}

main() {
    ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
    // freopen("input.txt", "r", stdin);
    cin >> n >> s >> t;
    if(s > t)
        swap(s, t);
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            if(i == t) {
                add_t(dp[i][j], dp[i-1][j]);
                add_t(dp[i][j], dp[i-1][j-1]);
            }
            else {
                add_t(dp[i][j], dp[i-1][j-1]);
                add_t(dp[i][j], mt(j * (j + 1), dp[i-1][j+1]));
            }
        }
    }
    cout << dp[n][1] << endl;
    return 0;
}

Compilation message

kangaroo.cpp:27:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct