結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
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(p+M);
        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