Submission #986031

# Submission time Handle Problem Language Result Execution time Memory
986031 2024-05-19T16:31:51 Z vjudge1 Kangaroo (CEOI16_kangaroo) C++14
0 / 100
1 ms 344 KB
/*If we keep holding onto yesterday, what are we going to be tomorrow?*/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long int 
#define dbg if(debugg)
#define F first 
#define S second 

bool debugg = false;

template <typename T>
using order_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;

template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  

const int mod = 1000000007;
int n, s, e;
int dp[2002][2002];

void solve()
{
    cin >> n >> s >> e;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i ++){
        for(int j = 1; j <= n; j ++){
            if(i == s || i == e){
                dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
            }

            else{
                int x = (dp[i - 1][j + 1] * j) % mod;
                int y = (dp[i - 1][j - 1] * (j - 2 + (j < s) + (j < e))) % mod;
                dp[i][j] = (x + y) % mod;
            }
        }
    }

    cout << dp[n][1] << '\n';
}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
        
    int t = 1;
    // cin >> t;
    
    while(t--){
        solve();
    }

    return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -