#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 100000007;
int n;
int s, e;
ll DP[2002][2002];
inline void add(int i, int j, int ti, int tj, ll multiplier){
if(ti<0 || tj<0) return;
DP[i][j] = (DP[i][j] + DP[ti][tj] * multiplier) % MOD;
}
int main(){
scanf("%d %d %d", &n, &s, &e);
if(e<s) s=n+1-s, e=n+1-e;
DP[0][0] = 1;
for(int i=1; i<=n; i++){
for(int j=1; j<=n; j++){
if(i==s || i==e){
add(i, j, i-1, j, 1);
add(i, j, i-1, j-1, 1);
}
else{
add(i, j, i-1, j+1, j);
add(i, j, i-1, j-1, j-(i<s?0:i<e?1:2));
}
}
}
printf("%lld", DP[n][1]);
}
Compilation message
kangaroo.cpp: In function 'int main()':
kangaroo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d %d %d", &n, &s, &e);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |