結果

問題 No.1242 高橋君とすごろく
ユーザー takaygtakayg
提出日時 2020-10-02 23:02:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,011 bytes
コンパイル時間 2,586 ms
コンパイル使用メモリ 205,388 KB
最終ジャッジ日時 2025-01-15 01:07:58
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rrep(i, n) for(int i = (int)(n) - 1; i >= 0; i --)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define sll set<ll>
#define spll set<pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod2 998244353
#define inf 1000000000000000000
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rsort(a) sort(a.rbegin(), a.rend())
#define print(x) for(auto i : (x)) cout << i << " "; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// const ll dx[] = {-1,0,1,0,-1,-1,1,1};
// const ll dy[] = {0,-1,0,1,-1,1,-1,1};


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(15) << fixed;

    ll n, k; cin >> n >> k;
    vll a(k);
    sll s;
    rep(i, k) { 
        cin >> a[i];
        s.insert(a[i]);
    }
    bool flag = true;
    priority_queue<ll> queue;
    for (auto i : a) queue.push(i);

    while(queue.size() != 0) {
        auto i = queue.top(); queue.pop();
        for (int j = 1; j <= 6; j++) {
            if (i - j < 1 || (i - j) + (7 - j) >= n) continue;
            if (s.find((i - j) + (7 - j)) != s.end()) {
                queue.push(i - j);
                s.insert(i - j);
            }
        }
        if (s.find(1) != s.end()) {
            flag = false;
            break;
        }
        if (s.find(i - 1) != s.end() && s.find(i - 2) != s.end()) {
            flag = false;
            break;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

0