結果

問題 No.1242 高橋君とすごろく
ユーザー fine
提出日時 2020-10-03 00:38:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,709 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 169,744 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-20 02:52:29
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

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