結果

問題 No.2672 Subset Xor Sum
ユーザー LyricalMaestro
提出日時 2024-08-03 01:14:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 142,752 KB
最終ジャッジ日時 2024-08-03 01:14:59
合計ジャッジ時間 6,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2672


def main():
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for a in A:
        ans ^= a
    if ans != 0:
        print("No")
        return


    if N <= 16:
        for bit in range(1, 2 ** N - 1):
            ans = 0
            for i in range(N):
                if bit & (1 << i) > 0:
                    ans ^= A[i]

            if ans == 0:
                print("Yes")
                return
        print("No")
    else: 
        a_set = set()
        for a in A:
            if a not in a_set:
                b_array = []
                for b in a_set:
                    b_array.append(a ^ b)
                for b in b_array:
                    a_set.add(b)
                a_set.add(a)
            else:
                print("Yes")
                return
        
        print("No")


        



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