結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 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 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 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,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    ll n;
    int k;
    cin >> n >> k;
    VL a(k);
    rep(i,k) cin >> a[i];
    int hi = upper_bound(all(a), 1000) - a.begin();

    // 大きい側
    bool ok = true;
    for(int i = hi; i < k; i++){
        for(int j = i+1; j < k; j++){
            if (a[i]+1 == a[j] || a[i]+3 == a[j] || a[i]+5 == a[j]) ok = false;
        }
    }
    if (!ok){
        view("No");
        return 0;
    }

    // 小さい側
    vector<bool> ng(1001);
    for(int i = 0; i < hi; i++) ng[a[i]] = true;
    for(int x = 1000; x > 0; x--){
        for(int m = 1; m <= 3; m++){
            int x1 = x + m, x2 = x + (7-m);
            bool ngx1 = false, ngx2 = false;
            if (x2 > 1000) continue;
            for(int i = 0; i < hi; i++){
                if (ng[x1]) ngx1 = true;
                if (ng[x2]) ngx2 = true;
            }
            if (ngx1 && ngx2){
                ng[x] = true;
                break;
            }
        }
    }

    if (ng[1]) view("No");
    else view("Yes");
    return 0;
}
0