Submission #36732

# Submission time Handle Problem Language Result Execution time Memory
36732 2017-12-14T05:00:51 Z aome Kangaroo (CEOI16_kangaroo) C++14
100 / 100
19 ms 17880 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 2005;
const int mod = 1e9 + 7;

int n, st, ed;
int f[N][N];

void add(int &x, int y) {
	x = (x + y) >= mod ? x + y - mod : x + y;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> st >> ed;
	f[1][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (!f[i][j]) continue;
			if (i == st || i == ed) {
				if (j) add(f[i + 1][j], f[i][j]);
				add(f[i + 1][j + 1], f[i][j]);
			}
			else {
				if (j >= 2) add(f[i + 1][j - 1], 1LL * f[i][j] * (j - 1) % mod);
				int k = j - (i > st) - (i > ed) + 1;
				if (k > 0) add(f[i + 1][j + 1], 1LL * f[i][j] * k % mod);
			}
		}
	}
	cout << f[n + 1][1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17880 KB Output is correct
2 Correct 0 ms 17880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17880 KB Output is correct
2 Correct 0 ms 17880 KB Output is correct
3 Correct 0 ms 17880 KB Output is correct
4 Correct 0 ms 17880 KB Output is correct
5 Correct 3 ms 17880 KB Output is correct
6 Correct 0 ms 17880 KB Output is correct
7 Correct 0 ms 17880 KB Output is correct
8 Correct 0 ms 17880 KB Output is correct
9 Correct 0 ms 17880 KB Output is correct
10 Correct 0 ms 17880 KB Output is correct
11 Correct 0 ms 17880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17880 KB Output is correct
2 Correct 0 ms 17880 KB Output is correct
3 Correct 0 ms 17880 KB Output is correct
4 Correct 0 ms 17880 KB Output is correct
5 Correct 3 ms 17880 KB Output is correct
6 Correct 0 ms 17880 KB Output is correct
7 Correct 0 ms 17880 KB Output is correct
8 Correct 0 ms 17880 KB Output is correct
9 Correct 0 ms 17880 KB Output is correct
10 Correct 0 ms 17880 KB Output is correct
11 Correct 0 ms 17880 KB Output is correct
12 Correct 0 ms 17880 KB Output is correct
13 Correct 0 ms 17880 KB Output is correct
14 Correct 0 ms 17880 KB Output is correct
15 Correct 0 ms 17880 KB Output is correct
16 Correct 0 ms 17880 KB Output is correct
17 Correct 0 ms 17880 KB Output is correct
18 Correct 0 ms 17880 KB Output is correct
19 Correct 0 ms 17880 KB Output is correct
20 Correct 0 ms 17880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17880 KB Output is correct
2 Correct 0 ms 17880 KB Output is correct
3 Correct 0 ms 17880 KB Output is correct
4 Correct 0 ms 17880 KB Output is correct
5 Correct 3 ms 17880 KB Output is correct
6 Correct 0 ms 17880 KB Output is correct
7 Correct 0 ms 17880 KB Output is correct
8 Correct 0 ms 17880 KB Output is correct
9 Correct 0 ms 17880 KB Output is correct
10 Correct 0 ms 17880 KB Output is correct
11 Correct 0 ms 17880 KB Output is correct
12 Correct 0 ms 17880 KB Output is correct
13 Correct 0 ms 17880 KB Output is correct
14 Correct 0 ms 17880 KB Output is correct
15 Correct 0 ms 17880 KB Output is correct
16 Correct 0 ms 17880 KB Output is correct
17 Correct 0 ms 17880 KB Output is correct
18 Correct 0 ms 17880 KB Output is correct
19 Correct 0 ms 17880 KB Output is correct
20 Correct 0 ms 17880 KB Output is correct
21 Correct 0 ms 17880 KB Output is correct
22 Correct 3 ms 17880 KB Output is correct
23 Correct 3 ms 17880 KB Output is correct
24 Correct 19 ms 17880 KB Output is correct
25 Correct 16 ms 17880 KB Output is correct
26 Correct 19 ms 17880 KB Output is correct
27 Correct 19 ms 17880 KB Output is correct
28 Correct 9 ms 17880 KB Output is correct