結果

問題 No.1500 Super Knight
ユーザー shun2741shun2741
提出日時 2021-05-07 22:15:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,610 bytes
コンパイル時間 5,226 ms
コンパイル使用メモリ 260,340 KB
実行使用メモリ 4,952 KB
最終ジャッジ日時 2023-10-13 13:28:23
合計ジャッジ時間 6,036 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,604 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
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 AC 6 ms
4,900 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

// デバッグ表示
#define dump(x) cout << #x << ":" << (x) << endl;

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// modint
using mint = modint1000000007;
// using mint = modint998244353;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第2引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// コンビネーションを計算する関数
ll pow(ll N, ll k) {
    ll res = 1;
    for (ll i = 0; i < k; ++i) res *= N;
    return res;
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

ll B[400][400];

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    cin >> K;

    ll N = 20;

    Fill(B, -1);

    vector<ll> C(N+1);
    C[0] = 1;
    B[200][200] = 0;
    for(ll t=1; t<=N; t++){
        REP(i, 400){
            REP(j, 400){
                if(B[i][j] == t-1){
                    if(B[i-3][j-2] == -1) B[i-3][j-2] = t;
                    if(B[i-3][j] == -1) B[i-3][j] = t;
                    if(B[i-3][j+2] == -1) B[i-3][j+2] = t;

                    if(B[i+3][j-2] == -1) B[i+3][j-2] = t;
                    if(B[i+3][j] == -1) B[i+3][j] = t;
                    if(B[i+3][j+2] == -1) B[i+3][j+2] = t;

                    if(B[i-2][j-3] == -1) B[i-2][j-3] = t;
                    if(B[i][j-3] == -1) B[i][j-3] = t;
                    if(B[i+2][j-3] == -1) B[i+2][j-3] = t;

                    if(B[i-2][j+3] == -1) B[i-2][j+3] = t;
                    if(B[i][j+3] == -1) B[i][j+3] = t;
                    if(B[i+2][j+3] == -1) B[i+2][j+3] = t;
                }
            }
        }
        ll count = 0;
        REP(i, 400){
            REP(j, 400){
                if(B[i][j] == t) count++;
            }
        }
        C[t] = count;
    }

    // cout << 0 << " " << C[0] << endl;
    // for(ll i=1; i<20; i++){
    //     cout << i << " " << C[i] << endl;
    // }

    if(K < 10){
        cout << C[K] << endl;
    }
    else{
        mint ans = (mint(17)*mint(K) - mint(14)) * mint(4);
        cout << ans.val() << endl;
    }
    return 0;
}
0