| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 591329 | messiuuuuu | 캥거루 (CEOI16_kangaroo) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define task "C"
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;
const int MAXN = 2e3 + 5;
const ll INF = 1e18 + 5;
const int MOD = 1e9 + 7;
int n, cs, cf;
void Input()
{
cin >> n >> cs >> cf;
}
int dp[MAXN][MAXN];
void add(int& a, int b)
{
a += b;
if (a > MOD)
a -= MOD;
}
int mul(int a, int b)
{
return 1ll * a * b % MOD;
}
void Solve()
{
if (cs > cf)
swap(cs, cf);
dp[0][0] = 1;
for (int i = 0; i < n; i++)
{
for (int j = 0; j <= i; j++)
{
if (i + 1 == cs || i + 1 == cf)
{
add(dp[i + 1][j], dp[i][j]);
if (j > 0)
add(dp[i + 1][j - 1], mul(dp[i][j], j));
} else
{
add(dp[i + 1][j + 1], dp[i][j]);
if (j > 0)
add(dp[i + 1][j - 1], mul(dp[i][j], mul(j, j - 1)));
if (i > cs && j > 0)
add(dp[i + 1][j - 1], mul(dp[i][j], j));
if (i > cf && j > 0)
add(dp[i + 1][j - 1], mul(dp[i][j], j));
}
}
}
cout << dp[n][1];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
if (fopen(task".INP","r"))
{
freopen(task".INP","r",stdin);
//freopen(task".OUT","w",stdout);
}
Input();
Solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
