Submission #485635

#TimeUsernameProblemLanguageResultExecution timeMemory
485635inluminasKangaroo (CEOI16_kangaroo)C++14
0 / 100
0 ms204 KiB
#include"bits/stdc++.h" using namespace std; #define ll long long #define endl "\n" #define fastio ios_base::sync_with_stdio(false) #define inf LLONG_MAX const int lmt=2e3+1; const ll mod=1e9+7; int n,cf,cs; bool state[lmt]; ll ans; ll f(ll cnt){ if(!cnt) return 1LL; ll res=1; for(int i=1;i<=cnt;i++) res=(res*i)%mod; return res; } void solve(){ for(int i=2;i<=n;i++) state[i]=state[i-1]^1; ll o=0,z=0; for(int i=3;i<n-1;i++){ if(state[i]) o++; else z++; } ll stan=(f(o)*f(z))%mod; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(i==cf || i==cs || j==cf || j==cs) continue; if((i>cs)!=state[2]) continue; if((j>cf)!=state[n-1]) continue; if((2==n-1)!=(i==j)) continue; ans=(ans+stan)%mod; } } return; } int main(){ fastio; cin>>n>>cs>>cf; if(n==2){ cout<<1<<endl; return 0; } state[1]=0; solve(); state[1]=1; solve(); cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...