Submission #559569

#TimeUsernameProblemLanguageResultExecution timeMemory
559569Pherokung캥거루 (CEOI16_kangaroo)C++14
100 / 100
26 ms22940 KiB
#include<bits/stdc++.h> using namespace std; #define N 2005 #define ll long long const int mod = 1e9+7; int n,cs,cf,d=0; ll dp[N][N],ans; int main(){ scanf("%d%d%d",&n,&cs,&cf); dp[0][0] = 1; for(int idx=1;idx<=n;idx++){ for(int comp=1;comp<=idx;comp++){ if(idx == cs || idx == cf){ dp[idx][comp] += dp[idx-1][comp]; dp[idx][comp] %= mod; dp[idx][comp] += dp[idx-1][comp-1]; dp[idx][comp] %= mod; } else{ int v = comp - (idx > cs) - (idx > cf); dp[idx][comp] += dp[idx-1][comp-1] * (v); dp[idx][comp] %= mod; dp[idx][comp] += dp[idx-1][comp+1] * (comp); dp[idx][comp] %= mod; } } } printf("%lld",dp[n][1]); }

Compilation message (stderr)

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