結果

問題 No.2672 Subset Xor Sum
ユーザー Daiki OkayamaDaiki Okayama
提出日時 2024-03-15 22:28:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 171,536 KB
最終ジャッジ日時 2024-03-16 17:42:34
合計ジャッジ時間 6,584 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,600 KB
testcase_01 AC 43 ms
55,600 KB
testcase_02 AC 47 ms
63,792 KB
testcase_03 AC 43 ms
55,600 KB
testcase_04 AC 44 ms
55,600 KB
testcase_05 AC 48 ms
63,792 KB
testcase_06 AC 49 ms
63,792 KB
testcase_07 AC 47 ms
61,680 KB
testcase_08 AC 47 ms
61,680 KB
testcase_09 AC 49 ms
61,680 KB
testcase_10 AC 49 ms
63,792 KB
testcase_11 AC 49 ms
63,792 KB
testcase_12 AC 48 ms
61,680 KB
testcase_13 AC 48 ms
61,680 KB
testcase_14 AC 47 ms
61,680 KB
testcase_15 AC 47 ms
61,680 KB
testcase_16 AC 47 ms
61,680 KB
testcase_17 AC 47 ms
61,680 KB
testcase_18 AC 48 ms
61,680 KB
testcase_19 AC 47 ms
61,680 KB
testcase_20 AC 47 ms
61,680 KB
testcase_21 AC 47 ms
61,680 KB
testcase_22 AC 43 ms
55,600 KB
testcase_23 AC 43 ms
55,600 KB
testcase_24 AC 44 ms
55,600 KB
testcase_25 AC 43 ms
55,600 KB
testcase_26 AC 49 ms
63,920 KB
testcase_27 AC 52 ms
63,920 KB
testcase_28 AC 48 ms
63,920 KB
testcase_29 AC 48 ms
63,920 KB
testcase_30 AC 47 ms
61,680 KB
testcase_31 AC 179 ms
161,852 KB
testcase_32 AC 97 ms
105,348 KB
testcase_33 AC 93 ms
103,400 KB
testcase_34 AC 131 ms
116,040 KB
testcase_35 AC 180 ms
161,988 KB
testcase_36 AC 135 ms
123,524 KB
testcase_37 AC 142 ms
129,960 KB
testcase_38 AC 103 ms
107,472 KB
testcase_39 AC 188 ms
171,536 KB
testcase_40 AC 68 ms
82,748 KB
testcase_41 AC 114 ms
106,248 KB
testcase_42 AC 139 ms
128,584 KB
testcase_43 AC 123 ms
113,028 KB
testcase_44 AC 146 ms
145,032 KB
testcase_45 AC 121 ms
113,124 KB
testcase_46 AC 47 ms
61,672 KB
testcase_47 AC 52 ms
66,396 KB
testcase_48 AC 48 ms
61,672 KB
testcase_49 AC 48 ms
61,672 KB
testcase_50 AC 47 ms
61,672 KB
testcase_51 AC 53 ms
66,396 KB
testcase_52 AC 54 ms
66,396 KB
testcase_53 AC 54 ms
68,444 KB
testcase_54 AC 53 ms
64,172 KB
testcase_55 AC 51 ms
66,268 KB
testcase_56 AC 48 ms
61,672 KB
testcase_57 AC 50 ms
63,792 KB
testcase_58 AC 51 ms
64,184 KB
testcase_59 AC 43 ms
55,600 KB
testcase_60 AC 47 ms
61,672 KB
testcase_61 AC 50 ms
61,672 KB
testcase_62 AC 52 ms
66,396 KB
testcase_63 AC 52 ms
64,184 KB
testcase_64 AC 53 ms
66,396 KB
testcase_65 AC 52 ms
66,396 KB
testcase_66 AC 43 ms
55,600 KB
testcase_67 AC 43 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import functools
import operator

n = int(input())
a = list(map(int, input().split()))

x = functools.reduce(operator.xor, a)

if x != 0:
    print("No")
    exit()


# dp[i][b] := i番目までの整数を利用して、xor が b になるような組み合わせが存在するか
dp: list[set[int]] = [set() for _ in range(n - 1)]

dp[0].add(a[0])

for i in range(1, n - 1):
    for b in dp[i - 1]:
        dp[i].add(b)
        dp[i].add(b ^ a[i])
    if 0 in dp[i]:
        print("Yes")
        break
else:
    print("No")
0