結果

問題 No.1242 高橋君とすごろく
ユーザー finefine
提出日時 2020-10-03 00:38:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,709 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 168,760 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 08:47:04
合計ジャッジ時間 2,440 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    ll n;
    int K;
    cin >> n >> K;

    vector<ll> a(K);
    for (int i = 0; i < K; i++) {
        cin >> a[i];
    }

    vector<int> ban(30, false);
    for (int i = K - 2; i >= 0; i--) {
        ll diff = a[i + 1] - a[i];
        if (diff == 1) {
            if (a[i] - 8 >= 1) {
                cout << "No\n";
                return 0;
            } else {
                ban[a[i]] = true;
                ban[a[i] + 1] = true;
                for (int j : {3, 5, 6}) {
                    if (a[i] - j > 0) ban[a[i] - j] = true;
                }
            }
        } else if (diff == 3) {
            if (a[i] - 5 >= 1) {
                cout << "No\n";
                return 0;
            } else {
                ban[a[i]] = true;
                ban[a[i] + 3] = true;
                for (int j : {2, 3}) {
                    if (a[i] - j > 0) ban[a[i] - j] = true;
                }
            }
        } else if (diff == 5) {
            if (a[i] - 9 >= 1) {
                cout << "No\n";
                return 0;
            } else {
                ban[a[i]] = true;
                ban[a[i] + 5] = true;
                for (int j : {1, 4, 6, 7}) {
                    if (a[i] - j > 0) ban[a[i] - j] = true;
                }
            }
        }
    }

    for (int i = 20; i >= 1; i--) {
        for (int j = 1; j <= 3; j++) {
            if (ban[i + j] && ban[i + 7 - j]) {
                ban[i] = true; 
            }
        }
    }
    cout << (ban[1] ? "No" : "Yes") << newl;
    
    return 0;
}
0