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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118325vjudge1Kangaroo (CEOI16_kangaroo)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define in insert #define fi first #define se second #define vl vector<ll> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int sz = 2005; /// mind this $$ const int MAX = 2e6 + 123; const int BS = 61; const ll inf = 1e17; const int mod = 998244353; ll dp[2][sz][sz]; void solve(){ ll n, k, i, j; cin >> n >> k; dp[0][1][1] = 1; for(i = 2; i <= n; i++){ for(j = 1; j <= n; j++){ for(int t = 0; t < 2; t++){ int open = j - t; if(open >= k){ continue; } dp[t][i][j] = (dp[t][i][j] + (dp[t][i - 1][j - 1] * (j - t)) % mod) % mod; dp[t][i][j] = (dp[t][i][j] + (dp[t][i - 1][j + 1] * j) % mod) % mod; if(open + 1 < k){ dp[t][i][j] = (dp[t][i][j] + (dp[t][i - 1][j] * (j - t)) % mod) % mod; } dp[t][i][j] = (dp[t][i][j] + (dp[t][i - 1][j] * j) % mod) % mod; if(t == 1){ dp[t][i][j] = (dp[0][i - 1][j] + dp[0][i - 1][j - 1]) % mod; } } } } cout << dp[n][1] << endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll t = 1; // cin >> t; while(t--){ solve(); } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...