Submission #1004069

# Submission time Handle Problem Language Result Execution time Memory
1004069 2024-06-21T04:16:01 Z ef10 Kangaroo (CEOI16_kangaroo) C++17
100 / 100
40 ms 31836 KB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define MODULE 1000000007

int main() {
	std::ifstream input;
    input.open("kangaroo.in");
    std::ofstream output;
    output.open("kangaroo.out");
	LL N, s, f;
	cin >> N >> s >> f;
	LL dp[N+5][N+5]; memset(dp,0,sizeof(dp));
	dp[1][1] = 1;
	for (LL i = 2; i <= N; i++) {
		for (LL j = 1; j <= N; j++) {
			if (i == s || i == f) {
				dp[i][j] += dp[i-1][j-1];
				dp[i][j] %= MODULE;
				dp[i][j] += dp[i-1][j];
				dp[i][j] %= MODULE;
				continue;
			}
			if (j-(i>s)-(i>f) > 0) {
				dp[i][j] += (dp[i-1][j-1] * (j-(i>s)-(i>f))) % MODULE;
				dp[i][j] %= MODULE;
			}
			dp[i][j] += (dp[i-1][j+1]*j) % MODULE;
			dp[i][j] %= MODULE;
		}
	}
	cout << dp[N][1] << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 604 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 5 ms 3928 KB Output is correct
22 Correct 5 ms 4188 KB Output is correct
23 Correct 6 ms 4956 KB Output is correct
24 Correct 40 ms 31788 KB Output is correct
25 Correct 40 ms 31836 KB Output is correct
26 Correct 40 ms 31836 KB Output is correct
27 Correct 39 ms 31580 KB Output is correct
28 Correct 22 ms 17992 KB Output is correct