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

#TimeUsernameProblemLanguageResultExecution timeMemory
463503huukhangKangaroo (CEOI16_kangaroo)C++17
100 / 100
31 ms31784 KiB
/* Khangnh's code “You can either experience the pain of discipline or the pain of regret. The choice is yours.” */ // - Only when necessary :d // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> using namespace std; #define fileopen(a, b) freopen(((string)a + ".inp").c_str(), "r", stdin); freopen(((string)b + ".out").c_str(), "w", stdout); #define ll long long // #define int long long #define ld long double #define fi first #define se second #define pb push_back #define pf push_front #define pob pop_back #define pof pop_front #define eb emplace_back typedef pair<int, int> pii; const ll mod = 1e9 + 7; const ll inf = 1e9 + 7; const double eps = 1e-9; inline void sadd(ll &x, const ll &y) {x = (x + y)%mod;} inline ll mmul(const ll &x, const ll &y) {return (x*y)%mod;} int n, s, e; ll dp[2005][2005]; void solve() { cin >> n >> s >> e; memset(dp, 0, sizeof(dp)); dp[1][1] = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { if (i + 1 == s || i + 1 == e) { sadd(dp[i + 1][j + 1], dp[i][j]); sadd(dp[i + 1][j], dp[i][j]); } else { sadd(dp[i + 1][j - 1], mmul(dp[i][j], j - 1)); sadd(dp[i + 1][j + 1], mmul(dp[i][j], j + 1 - (i + 1 > s) - (i + 1 > e))); } } } cout << dp[n][1]; } signed main() { #ifdef LOCAL fileopen("input", "output"); auto start = clock(); #endif #ifndef LOCAL // fileopen("LAH", "LAH"); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int test = 1; // cin >> test; for (int tc = 1; tc <= test; ++tc) solve(); #ifdef LOCAL auto end = clock(); cout << "\n\nExecution time : " << double(end - start)/CLOCKS_PER_SEC << "[s]"; #endif return 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...