제출 #1005073

#제출 시각아이디문제언어결과실행 시간메모리
1005073erering캥거루 (CEOI16_kangaroo)C++17
6 / 100
2066 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define pb push_back #define ll long long #define int long long const long long inf=1e18; const int MOD=1e9+7; const int N=41; int n,cs,cf,ans=0; bool s[N]; void func(int i,int cnt,bool flag){ if(cnt==n){ if(i==cf){ ans++; ans%=MOD; } return; } if(flag){ for(int j=i+1;j<=n;j++){ if(!s[j]){ if(j==cf && cnt<n-1)continue; s[j]=1; cnt++; func(j,cnt,0); cnt--; s[j]=0; } } } else{ for(int j=i-1;j>0;j--){ if(!s[j]){ if(j==cf && cnt<n-1)continue; s[j]=1; cnt++; func(j,cnt,1); cnt--; s[j]=0; } } } } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>cs>>cf; s[cs]=1; func(cs,1,0); for(int i=0;i<=n;i++)s[i]=0; s[cs]=1; func(cs,1,1); cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...