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

#TimeUsernameProblemLanguageResultExecution timeMemory
153401lycKangaroo (CEOI16_kangaroo)C++14
100 / 100
18 ms14200 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef pair<ii, int> ri3; #define mp make_pair #define pb push_back #define fi first #define sc second #define SZ(x) (int)(x).size() #define ALL(x) begin(x), end(x) #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define RFOR(i, a, b) for (int i = a; i >= b; --i) const int MOD = 1e9 + 7; const int MAXN = 2005; int N, S, F; int dp[MAXN][MAXN]; int main() { //freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); cin >> N >> S >> F; dp[N+1][1] = 1; int done = 2; RFOR(i,N,1){ FOR(j,1,i){ if (i == S or i == F) dp[i][j] = (dp[i+1][j] + dp[i+1][j+1]) % MOD; else dp[i][j] = ((ll)dp[i+1][j-1] * (j-1) + (ll)dp[i+1][j+1] * (j+1 - done)) % MOD; } if (i == S or i == F) --done; } cout << dp[2][1] << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...