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

#TimeUsernameProblemLanguageResultExecution timeMemory
385217pure_memKangaroo (CEOI16_kangaroo)C++14
100 / 100
22 ms23020 KiB
#include <bits/stdc++.h> #define X first #define Y second #define MP make_pair #define ll long long using namespace std; const int N = 2003; const ll mod = 1e9 + 7, INF = 1e18; int n, cf, cs; ll dp[N][N]; int main () { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> cs >> cf; if(cs > cf) swap(cf, cs); dp[n + 1][0] = 1; for(int i = n;i >= 1;i--){ for(int j = 0;j <= n - i + 1;j++){ if(i > cf){ dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * j * (j + 1)) % mod; } else if(i == cf){ dp[i][j] = (dp[i + 1][j] + dp[i + 1][j + 1] * (j + 1)) % mod; } else if(cs < i){ dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * (j + 1) * (j + 1)) % mod; } else if(cs == i){ dp[i][j] = (dp[i + 1][j] + dp[i + 1][j + 1] * (j + 1)) % mod; } else{ dp[i][j] = ((j ? dp[i + 1][j - 1]: 0) + dp[i + 1][j + 1] * (j + 2) * (j + 1)) % mod; } } } cout << dp[2][0]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...