Submission #465451

# Submission time Handle Problem Language Result Execution time Memory
465451 2021-08-16T07:04:06 Z fuad27 Kangaroo (CEOI16_kangaroo) C++17
100 / 100
31 ms 31908 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mod 1000000007
#define MAXN 2010
#define int long long
void solve() {
	ll n, s , e;
	cin >> n >> s >> e;
	ll dp[n+10][n+10] = {0};
	dp[1][1] = 1;
	for(int i = 2;i<=n;i++) {
		for(int j = 1;j<=i;j++) {
			if(i == s or i == e) {
				dp[i][j] = (dp[i-1][j-1]+dp[i-1][j])%mod;
			}
			else {
				dp[i][j] = (dp[i-1][j+1]*j%mod + dp[i-1][j-1] * (j - (s<i) - (e<i))%mod)%mod;
			}
		}
	}
	cout<<dp[n][1]<<endl;
}
int32_t main () {/*
	#ifndef ONLINE_JUDGE
	freopen("stdin", "r", stdin);
	freopen("stdout", "w", stdout);
	freopen("stderr", "w", stderr);
	#endif*/
	//cin >> t;
		solve();
	return 0;
}



# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 548 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 548 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 4 ms 3676 KB Output is correct
22 Correct 4 ms 4128 KB Output is correct
23 Correct 4 ms 4812 KB Output is correct
24 Correct 31 ms 31820 KB Output is correct
25 Correct 30 ms 31908 KB Output is correct
26 Correct 30 ms 31876 KB Output is correct
27 Correct 30 ms 31616 KB Output is correct
28 Correct 17 ms 17964 KB Output is correct