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

#TimeUsernameProblemLanguageResultExecution timeMemory
67216GoogalKangaroo (CEOI16_kangaroo)C++14
100 / 100
80 ms23808 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int NMAX = 2 * 1e3 + 1e2; const ll MOD = 1e9 + 7; ll n, st, fn; ll res; ll dp[NMAX][NMAX]; int main() { ios::sync_with_stdio(false); cin >> n >> st >> fn; dp[0][0] = 1; for(ll i = 1; i < n; i++) { if(i == st || i == fn) { for(int j = 0; j < i; j++) (dp[i][j] += dp[i - 1][j]) %= MOD; for(int j = 1; j < i; j++) (dp[i][j - 1] += dp[i - 1][j] * j % MOD) %= MOD; continue; } for(ll j = 0; j < i; j++) { if(j >= 2){ (dp[i][j - 1] += dp[i - 1][j] * j % MOD * (j - 1) % MOD) %= MOD; } if(i >= st){ (dp[i][j - 1] += dp[i - 1][j] * j % MOD) %= MOD; } if(i >= fn){ (dp[i][j - 1] += dp[i - 1][j] * j % MOD) %= MOD; } (dp[i][j + 1] += dp[i - 1][j]) %= MOD; } } cout << dp[n - 1][0] << '\n'; return 0; }

Compilation message (stderr)

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:25:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int j = 1; j < i; j++)
         ^~~
kangaroo.cpp:27:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
           continue;
           ^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...