# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
474833 | 2021-09-20T03:24:35 Z | ntabc05101 | 캥거루 (CEOI16_kangaroo) | C++14 | 1 ms | 332 KB |
#include<bits/stdc++.h> using namespace std; #define taskname "kangaroo" const int mxN = 2000; const int mod = 1e9 + 7; int n, cs, cf; int dp[mxN + 5][mxN + 5]; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> cs >> cf; dp[1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == cs || i == cf) { dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % mod; } else { dp[i][j] = 1ll * dp[i - 1][j + 1] * j % mod; (dp[i][j] += 1ll * dp[i - 1][j - 1] * (j - (i > cs) - (i > cf))) %= mod; } } } cout << dp[n][1] << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Incorrect | 1 ms | 332 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |