(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #316932

#TimeUsernameProblemLanguageResultExecution timeMemory
316932KuuhakuKangaroo (CEOI16_kangaroo)C++17
100 / 100
91 ms14200 KiB
#define tasknames "Kangaroo" #include <iostream> #include <stdio.h> using namespace std; const int maxn=2e3+2; int n, cs, cf, dp[maxn][maxn], mod=1e9+7; void Enter() { cin>>n>>cs>>cf; if(cs>cf)swap(cs,cf); dp[1][0]=1; for(int i=1;i<=n;i++) for(int j=0;j<=i;j++) { if(i==cs||i==cf) { dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod; if(j)dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod; } else { if(i>cf) dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod; if(i>cs) dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*dp[i][j]%mod)%mod; dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod; dp[i+1][j-1]=(dp[i+1][j-1]+1ll*j*(j-1)*dp[i][j]%mod)%mod; } } cout<<dp[n][0]; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if(fopen(tasknames".INP","r")) { freopen(tasknames".INP","r",stdin); freopen(tasknames".OUT","w",stdout); } Enter(); }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:40:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   40 |      freopen(tasknames".INP","r",stdin);
      |      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         freopen(tasknames".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...