# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333747 | 2020-12-07T15:49:51 Z | phathnv | Kangaroo (CEOI16_kangaroo) | C++11 | 1 ms | 492 KB |
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "kangaroo" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 2001; const int MOD = 1e9 + 7; int sum(int a, int b){ a += b; a -= (a >= MOD) * MOD; return a; } int mul(int a, int b){ return (ll) a * b % MOD; } int n, dp[N][N], cs, cf; void readInput(){ cin >> n >> cs >> cf; } void solve(){ dp[0][0] = 1; int fixed = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= i; j++) if (i == cs || i == cf) dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD; else dp[i][j] = sum(mul(dp[i - 1][j + 1], j), mul(dp[i - 1][j - 1], j - fixed)); fixed += (i == cs || i == cf); } cout << dp[n][1]; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); readInput(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 492 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |