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

#TimeUsernameProblemLanguageResultExecution timeMemory
125444win11905Kangaroo (CEOI16_kangaroo)C++11
100 / 100
93 ms31992 KiB
#include <bits/stdc++.h> #define long long long using namespace std; const int M = 1e9+7; const int N = 2e3+5; int n, s, t; long dp[N][N]; long solve(int i, int j) { if(j == 0) return 0; long &now = dp[i][j]; if(now != -1) return now; if(i == 1) return now = (j == 1 ? 1 : 0); if(i == s || i == t) return now = (solve(i-1, j-1) + solve(i-1, j)) % M; return now = (solve(i-1, j+1) * j + solve(i-1, j-1) * (j - (i > s ? 1 : 0) - (i > t ? 1 : 0))) % M; } int main() { memset(dp, -1, sizeof dp); scanf("%d %d %d", &n, &s, &t); printf("%lld\n", solve(n, 1)); }

Compilation message (stderr)

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