結果
問題 | No.2672 Subset Xor Sum |
ユーザー |
![]() |
提出日時 | 2024-05-26 16:26:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 626 bytes |
コンパイル時間 | 772 ms |
コンパイル使用メモリ | 81,960 KB |
実行使用メモリ | 142,036 KB |
最終ジャッジ日時 | 2024-12-20 20:22:07 |
合計ジャッジ時間 | 7,135 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 |
ソースコード
N = int(input())A = list(map(int, input().split()))xor = 0for i in range(N):xor ^= A[i]if xor:exit(print("No"))if N == 2:if A[0] == 0:print("Yes")else:print("No")exit()S = set()for i in range(N):if A[i] in S:exit(print("Yes"))S.add(A[i])L = list(S)dp = [False]*(1<<14)dp[0] = TruedpN = [False]*(1<<14)for i in range(len(L)-1):for j in range(1<<14):if dp[j]:dpN[j] = Trueif not j ^ L[i]:exit(print("Yes"))dpN[j^L[i]] = Truedp = dpN[:]dpN = [False]*(1<<14)print("No")