結果

問題 No.2672 Subset Xor Sum
ユーザー 👑 KA37RI
提出日時 2024-03-16 12:38:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 974 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 111,616 KB
最終ジャッジ日時 2024-09-30 04:29:28
合計ジャッジ時間 13,022 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 66
権限があれば一括ダウンロードができます

ソースコード

diff #

def ret(b):
  print("Yes" if b else "No")

def solve(n, a):
  allxor = 0
  for ai in a:
    allxor ^= ai
  if allxor != 0:
    return False

  if n > 5000:
    return True

  ok = [False] * 16384
  ok[8192|a[0]] = True

  for ai in a[1:]:
    nxt = [False] * 16384
    for x in range(16384):
      if ok[x]:
        nxt[x^ai] = True
        nxt[x&8191] = True
    ok = nxt

  return ok[0]

n = int(input())
a = [int(x) for x in input().split()]
ret(solve(n, a))
0