結果

問題 No.2024 Xer
ユーザー jakujaku12
提出日時 2022-07-29 23:27:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 124,536 KB
最終ジャッジ日時 2024-07-19 17:00:15
合計ジャッジ時間 7,899 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop


N,X=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B=[a^X for a in A]
if min(A)>min(B):
    A=sorted(B)
    B=[a^X for a in A]
    BB=[(a^X,i) for i,a in enumerate(A)]
else:
    BB=[(b,i) for i,b in enumerate(B)]
# print(A)
# print(B)
heapify(BB)
flag=[0]*N
now=1
v=A[0]
flag[0]=1
aorb=1
res=[0]
while len(res)<N:
    # print(res)
    if aorb:
        f=1
        while f and len(BB):
            # print(f)
            nex,ind=heappop(BB)
            f=flag[ind]
        if nex>v:
            v=nex
            flag[ind]=1
            res.append(ind)
            aorb=0
        else:
            print("No")
            exit()
    else:
        # print("!")
        while now<N and flag[now]:
            # print(now,now)
            now+=1
        if now==N:
            print("No")
            exit()
            break
        else:
            nex=A[now]
            if nex>v:
                v=nex
                flag[now]=1
                now+=1
                res.append(now-1)
                aorb=1
            else:
                print("No")
                exit()
# print(res)
ans=1
for i in range(N-1):
    if i%2:
        if A[res[i]]<B[res[i+1]]:
            continue
        else:
            ans=0
    else:
        if B[res[i]]<A[res[i+1]]:
            continue
        else:
            ans=0
if ans:
    print("Yes")
else:
    print("No")
0