結果

問題 No.2672 Subset Xor Sum
ユーザー Theta
提出日時 2024-04-18 17:59:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 145,952 KB
最終ジャッジ日時 2024-10-10 11:19:39
合計ジャッジ時間 7,592 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 65 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce
from operator import xor


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if reduce(xor, A) != 0:
        print("No")
        return

    if len(set(A)) < len(A):
        print("Yes")
        return
    dp_table = [set((0,)), set()]

    for a_elm in A[:-1]:
        for xor_elm in dp_table[0]:
            dp_table[1].add(xor_elm)
            dp_table[1].add(xor_elm ^ a_elm)
            if xor_elm ^ a_elm == 0:
                print("Yes")
                return
        dp_table[0] = dp_table[1]
        dp_table[1] = set()
    print("No")


if __name__ == "__main__":
    main()
0