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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118249vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
37 ms31856 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 int main(){ int n, cs, cf, fi = 0; cin>>n>>cs>>cf; vector<vector<ll>> dp(n + 1, vector<ll>(n + 2, 0)); dp[0][0] = 1; for (int i = 1; i <= n; i++){ if (i == cs || i == cf){ fi++; } for (int j = 1; j <= n; j++){ if (i == cs || i == cf){ dp[i][j] += dp[i - 1][j - 1]; dp[i][j] += dp[i - 1][j]; dp[i][j] %= mod; continue; } dp[i][j] += dp[i - 1][j + 1] * j; if (j != 0){ dp[i][j] += max(j - fi, 0) * dp[i - 1][j - 1]; } dp[i][j] %= mod; } } cout<<dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...