#include <bits/stdc++.h>
#define oo 1000000007
#define ll long long
#define ld long double
#define ii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define vi vector<int>
#define vii vector<ii>
#define sz(a) (int)(a.size())
#define pb push_back
#define fto(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define fdto(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define bug(x) "["#x" = "<<(x)<<"] "
#define maxN 2005
using namespace std;
const int MOD = oo;
int n, cs, cf;
ll f[maxN][maxN];
int main() {
#ifndef EVAL
freopen("CEOI16_kangaroo.INP", "r", stdin);
freopen("CEOI16_kangaroo.OUT", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> cs >> cf;
f[1][1] = 1;
fto(i, 2, n) {
fto(j, 1, i) {
if (i == cs || i == cf) {
f[i][j] = (f[i-1][j-1] + f[i-1][j])%MOD;
} else {
f[i][j] = (f[i-1][j-1]*(j - (i > cs) - (i > cf))%MOD + f[i-1][j+1]*j%MOD)%MOD;
}
}
}
cout << f[n][1] << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
432 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
452 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
432 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
452 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
452 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
1 ms |
1228 KB |
Output is correct |
15 |
Correct |
1 ms |
1228 KB |
Output is correct |
16 |
Correct |
1 ms |
1184 KB |
Output is correct |
17 |
Correct |
1 ms |
1228 KB |
Output is correct |
18 |
Correct |
1 ms |
1088 KB |
Output is correct |
19 |
Correct |
1 ms |
1228 KB |
Output is correct |
20 |
Correct |
1 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
432 KB |
Output is correct |
6 |
Correct |
0 ms |
460 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
436 KB |
Output is correct |
9 |
Correct |
1 ms |
452 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
452 KB |
Output is correct |
12 |
Correct |
1 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
1100 KB |
Output is correct |
14 |
Correct |
1 ms |
1228 KB |
Output is correct |
15 |
Correct |
1 ms |
1228 KB |
Output is correct |
16 |
Correct |
1 ms |
1184 KB |
Output is correct |
17 |
Correct |
1 ms |
1228 KB |
Output is correct |
18 |
Correct |
1 ms |
1088 KB |
Output is correct |
19 |
Correct |
1 ms |
1228 KB |
Output is correct |
20 |
Correct |
1 ms |
1228 KB |
Output is correct |
21 |
Correct |
5 ms |
4556 KB |
Output is correct |
22 |
Correct |
4 ms |
4940 KB |
Output is correct |
23 |
Correct |
4 ms |
5580 KB |
Output is correct |
24 |
Correct |
20 ms |
22944 KB |
Output is correct |
25 |
Correct |
18 ms |
22896 KB |
Output is correct |
26 |
Correct |
18 ms |
22944 KB |
Output is correct |
27 |
Correct |
18 ms |
22844 KB |
Output is correct |
28 |
Correct |
11 ms |
15048 KB |
Output is correct |