結果

問題 No.2024 Xer
ユーザー umimelumimel
提出日時 2022-07-29 23:26:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 3,112 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 181,488 KB
実行使用メモリ 26,512 KB
最終ジャッジ日時 2023-09-26 23:13:22
合計ジャッジ時間 7,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 237 ms
15,432 KB
testcase_08 AC 189 ms
26,512 KB
testcase_09 AC 89 ms
7,672 KB
testcase_10 AC 189 ms
26,468 KB
testcase_11 AC 73 ms
9,744 KB
testcase_12 AC 152 ms
15,688 KB
testcase_13 AC 123 ms
10,732 KB
testcase_14 AC 303 ms
24,724 KB
testcase_15 AC 84 ms
9,460 KB
testcase_16 AC 166 ms
14,420 KB
testcase_17 AC 57 ms
7,472 KB
testcase_18 AC 73 ms
8,828 KB
testcase_19 AC 234 ms
17,280 KB
testcase_20 AC 116 ms
13,796 KB
testcase_21 AC 235 ms
19,868 KB
testcase_22 AC 214 ms
16,232 KB
testcase_23 AC 210 ms
16,280 KB
testcase_24 AC 237 ms
20,252 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 4 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 6 ms
4,380 KB
testcase_33 AC 4 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 3 ms
4,380 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 5 ms
4,380 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 3 ms
4,380 KB
testcase_41 AC 3 ms
4,376 KB
testcase_42 AC 3 ms
4,380 KB
testcase_43 AC 4 ms
4,376 KB
testcase_44 AC 5 ms
4,376 KB
testcase_45 AC 77 ms
8,240 KB
testcase_46 AC 19 ms
4,376 KB
testcase_47 AC 58 ms
6,396 KB
testcase_48 AC 1 ms
4,384 KB
testcase_49 AC 2 ms
4,376 KB
testcase_50 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll N_MAX = 2e5;

int main(){
    ll n, x;
    cin >> n >> x;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    ll md = 30;
    if(x == 0) md = 0;
    else{
        while (!((x >> md) & 1))
            md--;
    }

    map<ll, vector<ll>> mp;
    rep(i, n){
        mp[a[i]>>(md+1)].pb(a[i]);
    }

    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        vector<ll> zero;
        vector<ll> one;
        for(ll i : mp[(*itr).fi]){
            if((i>>md) & 1) one.pb(i);
            else zero.pb(i);
        }
        sort(all(zero));
        sort(all(one));

        ll nz = (ll)zero.size();
        ll no = (ll)one.size();
        if(abs(nz-no) >= 2){
            cout << "No" << endl;
            return 0;
        }

        rep(i, nz-1){
            if(zero[i] == zero[i+1]){
                cout << "No" << endl;
                return 0;
            }
        }

        rep(i, no-1){
            if(one[i] == one[i+1]){
                cout << "No" << endl;
                return 0;
            }
        }

        if((nz==0 && no==1) || (nz==1 && no==0)) continue;

        bool flag1 = false;
        bool flag2 = false;
        if(nz == no){
            // 0, 1, 0, 1
            flag1 = true;
            for(ll i=0; i<nz; i++){
                if(!(zero[i] < (ll)(one[i] ^ x) && (ll)(zero[i] ^ x) < one[i])){
                    flag1 = false;
                }
            }

            // 1, 0, 1, 0
            flag2 = true;
            for(ll i=0; i<nz; i++){
                if(!(one[i] < (ll)(zero[i] ^ x) && (ll)(one[i] ^ x) < zero[i])){
                    flag2 = false;
                }
            }

            if(!flag1 && !flag2){
                cout << "No" << endl;
                return 0;
            }
        }else if(nz < no){
            flag1 = true;
            for(ll i=0; i<nz; i++){
                if(!(one[i] < (ll)(zero[i] ^ x) && (ll)(one[i] ^ x) < zero[i])){
                    flag2 = false;
                }
            }
            if(!(zero[nz-1] < (ll)(one[no-1] ^ x) && (ll)(zero[nz-1] ^ x) < one[no-1])){
                flag1 = false;
            }

            if(!flag1){
                cout << "No" << endl;
                return 0;
            }
        }else if(no < nz){
            flag1 = true;
            for(ll i=0; i<no; i++){
                if(!(zero[i] < (ll)(one[i] ^ x) && (ll)(zero[i] ^ x) < one[i])){
                    flag2 = false;
                }
            }
            if(!(one[no-1] < (ll)(zero[nz-1] ^ x) && (ll)(one[no-1] ^ x) < zero[nz-1])){
                flag1 = false;
            }

            if(!flag1){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}
0