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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118257vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
30 ms23132 KiB
#include <bits/stdc++.h> // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") // #define ll long long #define int long long #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; const int oo = 1e9 + 9; const int MAX = 2000 + 5, LOGMAX = 20, B = 441, MOD = 1e9 + 7; int dp[MAX][MAX]; void solve(){ int n, cs, cf; cin >> n >> cs >> cf; dp[1][1] = 1; for(int i = 2; i <= n; i++){ for(int j = 1; j <= i; j++){ if(i == cs || i == cf){ dp[i][j] += dp[i - 1][j]; dp[i][j] += dp[i - 1][j - 1]; } else{ dp[i][j] += dp[i - 1][j - 1] * (j - (i > cs) - (i > cf)) % MOD; dp[i][j] += dp[i - 1][j + 1] * j % MOD; } dp[i][j] %= MOD; } } cout << dp[n][1] << '\n'; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int 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...