#include <bits/stdc++.h>
using namespace std;
const int mx=2000;
const int mod=1000000007;
typedef long long ll;
int n,m;
int st,en;
//(i,x,state);
map<int,int>mp;
int dp[mx][mx][3];
int solve(int i,int x,int dir){
if(i==en){
if(x==n){
return 1;}
return 0;
}
int &ret=dp[i][x][dir];
if(ret!=-1){return ret;}
ret=0;
if(dir==0){
for(int j=i+1;j<=n;j++){
if(mp[j]){continue;}
mp[j]=1;
ret=(ret+solve(j,x+1,dir^1))%mod;
mp[j]=0;
}
}else{
for(int j=i-1;j>=1;j--){
if(mp[j]){continue;}
mp[j]=1;
ret=(ret+solve(j,x+1,dir^1))%mod;
mp[j]=0;
}
}return ret%mod;
}
int main() {
cin>>n>>st>>en;
memset(dp,-1,sizeof(dp));
mp[st]=1;
cout<<(solve(st,1,0)+solve(st,1,1))%mod;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47232 KB |
Output is correct |
2 |
Incorrect |
27 ms |
47232 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47232 KB |
Output is correct |
2 |
Incorrect |
27 ms |
47232 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47232 KB |
Output is correct |
2 |
Incorrect |
27 ms |
47232 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47232 KB |
Output is correct |
2 |
Incorrect |
27 ms |
47232 KB |
Output isn't correct |