Submission #1295752

#TimeUsernameProblemLanguageResultExecution timeMemory
1295752beater2k7Kangaroo (CEOI16_kangaroo)C++20
0 / 100
17 ms23272 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,ll> using namespace std; ll dp[2005][2005]; const ll MOD=1e9+7; int main() { freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); int n,cs,cf;cin>>n>>cs>>cf; dp[1][1]=1; for (int i=2;i<=n;i++){ for (int j=1;j<=i;j++){ if (i==cs || i==cf){ dp[i][j]=dp[i-1][j-1]+dp[i-1][j]; dp[i][j]%=MOD; } else{ dp[i][j]=(dp[i-1][j+1]*j)%MOD+(dp[i-1][j-1]*(j-i>cs -i>cf))%MOD; dp[i][j]%=MOD; } } } cout<<dp[n][1]; return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen("kangaroo.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     freopen("kangaroo.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...