結果

問題 No.93 ペガサス
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-12 23:30:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,486 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 175,528 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-12 03:01:33
合計ジャッジ時間 3,848 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e7;

int main() {
    int N;
    cin >> N;

    vector<vector<ll>> dp(1, vector<ll>{1, 0});
    for (int i = 1; i < N; i++) {
        int n = dp.size();
        vector<vector<ll>> nxt(n + 1, vector<ll>(2, 0));
        if (i != N / 2) {
            for (int a = 0; a <= n; a++) {
                if (a < n)
                    nxt[a][1] += dp[a][1];
                if (a > 0) {
                    nxt[a][1] += 2 * dp[a - 1][0];
                    nxt[a][1] += dp[a - 1][1];
                }
                nxt[a][1] %= mod;

                if (a + 1 < n) {
                    nxt[a][0] += (a + 1) * dp[a + 1][0];
                    nxt[a][0] += a * dp[a + 1][1];
                }
                if (a < n) {
                    nxt[a][0] += max(i - a - 1, 0) * dp[a][0];
                    nxt[a][0] += (i - a) * dp[a][1];
                }
                nxt[a][0] %= mod;
            }
        } else {
            for (int a = 0; a <= n; a++) {
                if (a + 1 < n) {
                    nxt[a][0] += (a + 1) * dp[a + 1][0];
                    nxt[a][0] += (a + 1) * dp[a + 1][1];
                }
                if (a < n) {
                    nxt[a][0] += (i - a + 1) * dp[a][0];
                    nxt[a][0] += (i - a + 1) * dp[a][1];
                }

                nxt[a][0] %= mod;
            }
        }
        dp = nxt;
    }

    cout << dp[0][0] << endl;
}
0