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

#TimeUsernameProblemLanguageResultExecution timeMemory
1118256vjudge1Kangaroo (CEOI16_kangaroo)C++17
0 / 100
1 ms348 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; int dp[N][N]; void solve(){ int n,cs,cf,a = 0; cin >> n >> cs >> cf; dp[1][1] = 1; for(int i = 1; i <= n; i++){ if(n == cs || n == 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...