제출 #963011

#제출 시각아이디문제언어결과실행 시간메모리
963011Ghetto캥거루 (CEOI16_kangaroo)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; const int MAX_N = 2e3 + 5; const lint MOD = 1e9 + 7; int n; int s, f; lint mod(lint x) { return x % MOD; } lint dp[MAX_N][MAX_N]; void do_dp() { dp[1][1] = 1; for (int i = 1; i < n; i++) { for (int c = 1; c <= n; c++) { // cout << i << ", " << c << ": " << dp[i][c] << endl; if ((i + 1) == s || (i + 1) == f) { dp[i + 1][c + 1] = mod(dp[i + 1][c + 1] + dp[i][c]); dp[i + 1][c] = mod(dp[i + 1][c] + dp[i][c]); continue; } lint mult = c + 1; mult -= (bool) (i > s); mult -= (bool) (i > f); dp[i + 1][c + 1] = mod(dp[i + 1][c + 1] + mod(dp[i][c] * mult)); dp[i + 1][c - 1] = mod(dp[i + 1][c - 1] + mod(dp[i][c] * (c - 1))); } } } int main() { // freopen("kangaroo.in", "r", stdin); cin >> n >> s >> f; if (s > f) swap(s, f); do_dp(); cout << dp[n][1] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...