# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315750 | fadi57 | 캥거루 (CEOI16_kangaroo) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
ll dp[mx][mx][3];
ll solve(int i,int x,int dir){
if(i==en){
if(x==n){
return 1;}
return 0;
}
// ll &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;
}