結果

問題 No.2024 Xer
ユーザー 👑 NachiaNachia
提出日時 2022-07-29 23:02:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,674 bytes
コンパイル時間 1,297 ms
コンパイル使用メモリ 88,084 KB
実行使用メモリ 6,664 KB
最終ジャッジ日時 2023-09-26 22:36:49
合計ジャッジ時間 3,899 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 55 ms
4,380 KB
testcase_08 AC 45 ms
4,380 KB
testcase_09 AC 39 ms
5,528 KB
testcase_10 AC 48 ms
4,376 KB
testcase_11 AC 20 ms
4,380 KB
testcase_12 AC 33 ms
4,380 KB
testcase_13 AC 37 ms
4,380 KB
testcase_14 AC 59 ms
4,380 KB
testcase_15 AC 28 ms
4,376 KB
testcase_16 AC 40 ms
4,376 KB
testcase_17 AC 16 ms
4,380 KB
testcase_18 AC 23 ms
4,380 KB
testcase_19 AC 58 ms
4,376 KB
testcase_20 AC 24 ms
4,376 KB
testcase_21 AC 39 ms
4,380 KB
testcase_22 AC 40 ms
4,376 KB
testcase_23 AC 42 ms
4,376 KB
testcase_24 AC 41 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 3 ms
4,376 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 1 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 3 ms
4,380 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 35 ms
6,664 KB
testcase_46 AC 9 ms
4,380 KB
testcase_47 AC 25 ms
5,352 KB
testcase_48 AC 1 ms
4,376 KB
testcase_49 AC 1 ms
4,376 KB
testcase_50 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <atcoder/modint>

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


const i64 INF = 1001001001001001001;
using modint = atcoder::static_modint<998244353>;

const int t1 = 525118 ^ 36251;
const int t2 = 575820 ^ 36251;

bool solve(vector<u32> A, u32 X){
    sort(A.begin(), A.end());
    int N = A.size();
    vector<u32> A2[2];
    rep(i,N){
        if(A[i] < (A[i]^X)) A2[0].push_back(A[i]); else A2[1].push_back(A[i]);
    }

    bool ans = false;
    rep(t,2){
        vector<u32> A3;
        rep(i,N) rep(d,2) if(i < (int)A2[d].size()) A3.push_back(A2[d][i]);
        bool ok = true;
        rep(i,N-1) if(A3[i] >= (A3[i+1]^X) || (A3[i]^X) >= A3[i+1]) ok = false;
        ans = ans || ok;
        swap(A2[0], A2[1]);
    }
    return ans;
}

int main(){
    int N; cin >> N;
    u32 X; cin >> X;
    vector<u32> A(N); rep(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    u32 D = 1; while(D < X){ D *= 2; } D--;
    if(X == 0) D = 0;

    bool ans = true;
    while(A.size()){
        vector<u32> tmp = {A.back()}; A.pop_back();
        while(A.size()){
            u32 a = A.back();
            if((a&~D) != (tmp.back()&~D)) break;
            tmp.push_back(a);
            A.pop_back();
        }
        ans = ans && solve(move(tmp), X);
    }

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0