Submission #1118089

#TimeUsernameProblemLanguageResultExecution timeMemory
1118089vjudge1Kangaroo (CEOI16_kangaroo)C++17
51 / 100
18 ms15952 KiB
#pragma GCC optimize("O3")// ceoi 2016 day 1 p2//03:11 11-25-2024 #include<bits/stdc++.h> #define ll unsigned long long #define endl "\n" #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; ll dp[1001][1001]; int main() { AI //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ll n,cs,cf,fixe=0,i,j,mod=1e9+7; cin>>n; cin>>cs>>cf; dp[1][1]=1; for(i=0;i<=100;i++) { for(j=0;j<=1000;j++) dp[i][j]=0; } dp[1][1]=1; for(i=1;i<=n;i++) { if(i==cs or i==cf) fixe++; for(j=1;j<i;j++) { if(i==cs or i==cf) { dp[i][j+1]+=dp[i-1][j]; dp[i][j+1]%=mod; dp[i][j]+=dp[i-1][j]; dp[i][j]%=mod; } else { dp[i][j+1]+=(dp[i-1][j]*(j-fixe+1))%mod; dp[i][j-1]+=(dp[i-1][j]*(j-1))%mod; dp[i][j+1]%=mod; dp[i][j-1]%=mod; } } } cout<<dp[n][1]%mod; } /* Thanks to Rashad Mammadov */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...