Submission #110559

#TimeUsernameProblemLanguageResultExecution timeMemory
110559gumballKangaroo (CEOI16_kangaroo)C++14
0 / 100
29 ms32376 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...