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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118259vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
49 ms31828 KiB
#include <bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define vi vector<int> #define vll vector<ll> #define pii pair<int,int> #define vpii vector<pii> #define pb push_back #define fi first #define se second #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() const int N = 2005; const int M = 1000000007; ll dp[N][N]; void solve(){ ll n,cs,cf,a = 0; cin >> n >> cs >> cf; dp[1][1] = 1; for(int i = 1; i <= n; i++){ if(i == cs || i == cf) a++; for(int j = 1; j <= n; j++){ if(i == cs || i == cf){ dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % M; dp[i][j] = (dp[i][j] + dp[i-1][j]) % M; } else{ dp[i][j] = (dp[i][j] + (dp[i-1][j-1] * (j-a)) % M)%M; dp[i][j] = (dp[i][j] + (dp[i-1][j+1] * j) % M)%M; } } } cout << dp[n][1] << endl; } signed main(){ fast; 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...