Submission #558787

#TimeUsernameProblemLanguageResultExecution timeMemory
558787hibikiKangaroo (CEOI16_kangaroo)C++11
6 / 100
2071 ms564 KiB
#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007

int n,s,t;
long dp[2005][2005];

long solve(int nw,long comp)
{
    if(nw == 0) return 0;
    long &val = dp[nw][comp];
    if(val) return val;
    if(nw == 1) return val = (comp == 1)? 1 : 0;
    if(nw == s || nw == t)
        return val = (solve(nw - 1, comp - 1) + solve(nw - 1, comp)) % mod;
    long del = 0;
    if(nw > s) del++;
    if(nw > t) del++;
    return val = ( comp * solve(nw - 1, comp + 1) + (comp - del) * solve(nw - 1, comp - 1) ) % mod;
}

int main()
{
    scanf("%d %d %d",&n,&s,&t);
    printf("%ld\n",solve(n,1));
    return 0;
}

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d %d %d",&n,&s,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...