結果

問題 No.2024 Xer
ユーザー AEn
提出日時 2022-09-01 14:46:03
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,226 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 170,016 KB
最終ジャッジ日時 2024-11-14 05:58:33
合計ジャッジ時間 22,271 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 44 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    import random
    from heapq import heappop, heappush
    input = sys.stdin.readline

    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    h = []
    for i in range(N):
        heappush(h, (A[i], 0, i))
        heappush(h, (A[i]^X, 1, i))
    res1, res2 = [], []
    for i in range(2*N):
        n, w, idx = heappop(h)
        l1, l2 = len(res1), len(res2)
        w1, w2 = (l1+1)%2, l2%2
        if w1==w2:
            if w1!=w:
                exit(print('No'))
            else:
                if l1>l2:
                    if res1[l2] == idx:
                        res2.append(idx)
                    else:
                        res1.append(idx)
                else:
                    if res2[l1] == idx:
                        res1.append(idx)
                    else:
                        res2.append(idx)
        else:
            if w1 == w:
                res1.append(idx)
            else:
                res2.append(idx)
    if len(res1) != len(res2):
        exit(print("No"))
    else:
        for i in range(N):
            if res1[i] != res2[i]:
                exit(print("No"))
        print('Yes')
if __name__=='__main__':
    main()
0