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

#TimeUsernameProblemLanguageResultExecution timeMemory
446886aniervsKangaroo (CEOI16_kangaroo)C++17
100 / 100
29 ms22980 KiB
#ifdef LOCAL #include <prettyprint.hpp> #endif #include<bits/stdc++.h> #define endl '\n' #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define lg2(x) __lg(x) #define rem_dupl(x) sort(all(x)); x.erase(unique(all(x)), x.end()) using namespace std; typedef long long ll; typedef double db; typedef pair<int,int> ii; #define x first #define y second //mt19937 rand32(chrono::steady_clock::now().time_since_epoch().count()); //mt19937_64 rand64(chrono::steady_clock::now().time_since_epoch().count()); const db eps = 1e-9; const int maxn = (int)2e3 + 5; const ll mod = (int)1e9 + 7; // 998244353 ll mul(ll a, ll b){ return a * b % mod; } ll add(ll a, ll b){ return (a + b)%mod; } ll dp[maxn][maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.setf(ios::fixed); cout.precision(0); int n, s, t; cin >> n >> s >> t; dp[1][1] = 1; for(int i = 1; i < n; i++) for(int j = 1; j <= i; j++){ if(i + 1 == s or i + 1 == t){ dp[i+1][j] = add(dp[i + 1][j], dp[i][j]); dp[i+1][j+1] = add(dp[i + 1][j + 1], dp[i][j]); continue; } dp[i+1][j-1] = add(dp[i+1][j-1], mul(dp[i][j], j-1)); dp[i+1][j+1] = add(dp[i+1][j+1], mul(dp[i][j], j + 1 - (int)(i >= s) - (int)(i >= t))); } cout << dp[n][1]; 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...