Submission #683428

#TimeUsernameProblemLanguageResultExecution timeMemory
683428lamKangaroo (CEOI16_kangaroo)C++14
100 / 100
20 ms22984 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int mod = 1e9 + 7; const int maxn = 2010; int n,s,f; int dp[maxn][maxn]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>s>>f; dp[0][0]=1LL; for (int i=1; i<=n; i++) for (int j=1; j<=i; j++) { if (i==s) { dp[i][j]=(dp[i-1][j] + dp[i-1][j-1])%mod; } else if (i==f) { dp[i][j]=(dp[i-1][j] + dp[i-1][j-1])%mod; } else { dp[i][j]=(j) * dp[i-1][j+1]%mod; int val = j-2; if (i<s) val++; if (i<f) val++; dp[i][j] = (dp[i][j] + val*dp[i-1][j-1]%mod)%mod; } } cout<<dp[n][1]<<'\n'; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:29:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   29 |             if (i<s) val++; if (i<f) val++;
      |             ^~
kangaroo.cpp:29:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |             if (i<s) val++; if (i<f) val++;
      |                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...