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

#TimeUsernameProblemLanguageResultExecution timeMemory
228896quocnguyen1012Kangaroo (CEOI16_kangaroo)C++14
100 / 100
58 ms14200 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back #define ar array using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 2e3 + 5, mod = 1e9 + 7; int N, cs, cf, f[maxn][maxn]; void add(int & x, int y) { x += y; if(x >= mod) x -= mod; } signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); #endif // LOCAL cin >> N >> cs >> cf; if(cs > cf) swap(cs, cf); f[1][0] = 1; for(int i = 1; i <= N; ++i){ for(int j = 0; j <= i; ++j){ if(i == cs || i == cf){ add(f[i + 1][j], f[i][j]); if(j > 0) add(f[i + 1][j - 1], 1ll * f[i][j] * j % mod); } else{ if(i > cs && j > 0){ add(f[i + 1][j - 1], 1ll * f[i][j] * j % mod); } if(i > cf && j > 0){ add(f[i + 1][j - 1], 1ll * f[i][j] * j % mod); } add(f[i + 1][j + 1], f[i][j]); if(j > 1) add(f[i + 1][j - 1], 1ll * j * (j - 1) % mod * f[i][j] % mod); } } } cout << f[N][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...