(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 #377224

#TimeUsernameProblemLanguageResultExecution timeMemory
377224CaroLindaKangaroo (CEOI16_kangaroo)C++14
100 / 100
28 ms23020 KiB
#include <bits/stdc++.h> const int MAXN = 2010 ; const int MOD = 1e9+7 ; using namespace std ; int N , S , T ; long long dp[MAXN][MAXN] ; int main() { scanf("%d %d %d", &N , &S, &T ) ; if( S > T ) swap(S,T) ; dp[0][1] = 1 ; for(int i = 1 ; i < N ; i++ ) for(int j= 1 ; j <= N-i ; j++ ) { long long &ptr = dp[i][j] ; long long fat ; if( i == T || i == S ) { ptr = dp[i-1][j+1] + dp[i-1][j] ; if( ptr >= MOD ) ptr -= MOD ; continue ; } //creating new component fat = (j-1) + ( i > S ) + (i > T ) ; ptr = (fat * dp[i-1][j+1] ) % MOD ; //joining two components ptr += (dp[i-1][j-1] * (j-1) ) % MOD ; ptr %= MOD ; } long long ans = dp[N-1][1] ; printf("%lld\n", ans ) ; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  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...