#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,S,T,d[2020][2020],mo=1e9+7;
ll depe(ll aa,ll bb)
{
if(aa==(n+1)&&bb==1)return 1;
if(aa==(n+1))return 0;
if(bb<=0)return 0;
ll ret=d[aa][bb];
if(ret!=-1)return ret;
ret=0;
ll ujg=0;
if(aa>S)ujg++;
if(aa>T)ujg++;
if(aa==S||aa==T)
{
ret=(depe(aa+1,bb)+depe(aa+1,bb-1))%mo;
}
else
{
ret=(ret+depe(aa+1,bb+1)*(bb+1-ujg))%mo;
ret=(ret+depe(aa+1,bb-1)*(bb-1))%mo;
}
return d[aa][bb]=ret;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>S>>T;
memset(d,-1,sizeof(d));
cout<<depe(1,1)<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32376 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32248 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32376 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32248 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32376 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32248 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
32376 KB |
Output is correct |
2 |
Incorrect |
29 ms |
32248 KB |
Output isn't correct |