(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.

제출 #65728

#제출 시각아이디문제언어결과실행 시간메모리
65728Namnamseo캥거루 (CEOI16_kangaroo)C++17
100 / 100
66 ms23476 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n, s, f; ll ans; const ll mod = int(1e9) + 7; ll dp[2010][2010]; int main() { cin >> n >> s >> f; dp[0][0] = 1; for(ll i=1; i<n; ++i){ if(i == s || i == f){ 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 >= s){ (dp[i][j-1] += dp[i-1][j] * j % mod) %= mod; } if(i >= f){ (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] << endl; 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...