結果

問題 No.1500 Super Knight
ユーザー trineutrontrineutron
提出日時 2021-05-07 23:23:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,914 bytes
コンパイル時間 2,067 ms
コンパイル使用メモリ 210,684 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 14:45:03
合計ジャッジ時間 3,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 1 ms
4,352 KB
testcase_18 AC 1 ms
4,356 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 1 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 AC 1 ms
4,352 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint1000000007;

int main()
{
    int n;
    cin >> n;
    if (n < 10)
    {
        int ans = 0;
        vector<vector<bool>> table(6 * n + 1, vector<bool>(6 * n + 1));
        table.at(3 * n).at(3 * n) = true;
        const vector<int> dx{-3, -3, -3, -2, -2, 0, 0, 2, 2, 3, 3, 3};
        const vector<int> dy{-2, 0, 2, -3, 3, -3, 3, -3, 3, -2, 0, 2};
        for (int _ = 0; _ < n; _++)
        {
            vector<vector<bool>> newtable(6 * n + 1, vector<bool>(6 * n + 1));
            for (int i = 0; i <= 6 * n; i++)
            {
                for (int j = 0; j <= 6 * n; j++)
                {
                    if (not table.at(i).at(j))
                    {
                        continue;
                    }
                    for (int k = 0; k < 12; k++)
                    {
                        int newi = i + dx.at(k), newj = j + dy.at(k);
                        if (newi < 0 or 6 * n < newi or newj < 0 or 6 * n < newj)
                        {
                            continue;
                        }
                        newtable.at(newi).at(newj) = true;
                    }
                }
            }
            table = move(newtable);
        }
        for (int i = 0; i <= 6 * n; i++)
        {
            for (int j = 0; j <= 6 * n; j++)
            {
                if (table.at(i).at(j))
                {
                    ans++;
                }
            }
        }
        cout << ans << endl;
        return 0;
    }
    mint ans = mint(6) * n + 1;
    ans *= ans;
    if (n % 2)
    {
        ans--;
    }
    else
    {
        ans++;
    }
    ans /= 2;
    mint d = (n + 1) / 2;
    d *= 4 * d;
    if (n % 2)
    {
        d = mint(2) * n * (n + 1) - d;
    }
    ans -= d;
    cout << ans.val() << endl;
    return 0;
}
0