제출 #469739

#제출 시각아이디문제언어결과실행 시간메모리
469739TheScrasse캥거루 (CEOI16_kangaroo)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << #define INF (ll)1e18 #define mod 1000000007 #define maxn 2010 ll i, i1, j, k, k1, t, n, m, res, flag[10], a, b; ll st, nd, dp[maxn][maxn]; int main() { ios::sync_with_stdio(0); cin.tie(0); #if !ONLINE_JUDGE && !EVAL ifstream cin("input.txt"); ofstream cout("output.txt"); #endif cin >> n >> st >> nd; dp[1][1] = 1; for (i = 2; i <= n; i++) { for (j = 0; j <= n; j++) { if (i == st || i == nd) { if (j >= 1) dp[i][j] += dp[i - 1][j - 1]; if (st + nd != 3) dp[i][j] += dp[i - 1][j]; } else { if (j >= 1) dp[i][j] += dp[i - 1][j - 1]; dp[i][j] += dp[i - 1][j + 1]; dp[i][j] *= j; } dp[i][j] %= mod; } } /* for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cout << dp[i][j] << ' '; } cout << nl; } */ cout << dp[n][1] << nl; 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...