This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |