| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 878021 | vjudge1 | Kangaroo (CEOI16_kangaroo) | C++17 | 21 ms | 31836 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define task "a"
#define etr "\n"
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define bg begin
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define lwb lower_bound
#define upb upper_bound
#define range(x, l, r) x+l, x+1+r
#define all(x) (x).bg(), (x).end()
#define compact(x) x.resize(unique(all(x)) - (x).bg())
#define sq(x) ((x)*(x))
auto start = chrono::high_resolution_clock::now();
void start_timer()
{
    start = chrono::high_resolution_clock::now();
}
ld elapsed()
{
    auto current = chrono::high_resolution_clock::now();
    ld duration = chrono::duration_cast<chrono::nanoseconds>(current - start).count();
    return duration / 1e9;
}
void freop()
{
	freopen(task".inp", "r", stdin);
	freopen(task".out", "w", stdout);
}
template<typename U, typename V> istream& operator >> (istream& in, pair<U, V>& p)
{
	in >> p.fi >> p.se;
	return in;
}
template<typename U, typename V> ostream& operator << (ostream& out, pair<U, V> p)
{
	out << p.fi << ' ' << p.se;
	return out;
}
const int N=2e3, M=1e5, mod=1e9+7;
int n, cs, cf;
ll dp[N+5][N+5];
void process()
{
    cin >> n >> cs >> cf;
    dp[1][1] = 1;
    for (int i=2; i<=n; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (i != cf && i != cs)
            {
                dp[i][j] = dp[i-1][j+1] * j % mod;
                dp[i][j] += dp[i-1][j-1] * (j - (i > cs) - (i > cf)) % mod;
                dp[i][j] %= mod;
            } else dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;
            //cout << i << ' ' << j << ": " << dp[i][j] << etr;
        }
    }
    cout << dp[n][1];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t=1; //cin >> t;
	while (t--) process();
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
