結果

問題 No.1242 高橋君とすごろく
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-04-08 18:56:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 894 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 206,508 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 18:56:37
合計ジャッジ時間 3,147 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    //最大で12マス空けるように圧縮
    ll p=1, A, K, N, M, L=1;
    cin >> N >> K;
    vector<ll> ng2;
    //dp(i)=iから始めて出目に関わらずNに行けるか?
    for (int i=1; i<=K; i++){
        cin >> A;
        //p+1~A
        M = min(A-p, 13LL);
        L += M;
        ng2.push_back(L);
        p = A;
    }
    M = min(N-p, 13LL);
    L += M;

    vector<bool> dp(L+6);
    vector<bool> ng(L+6);
    for (auto x : ng2) ng[x] = 1;
    for (int i=L; i<=L+5; i++) dp[i] = 1;

    for (int i=L-1; i>=1; i--){
        if (ng[i]) continue;
        dp[i] = 1;
        for (int j=1; j<=6; j++){
            if (!dp[i+j] && !dp[i+(7-j)]) dp[i] = 0;
        }
    }

    cout << (dp[1] ? "Yes" : "No") << endl;

    return 0;
}
0