結果
| 問題 | No.2672 Subset Xor Sum |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2026-01-08 03:57:13 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 898 bytes |
| 記録 | |
| コンパイル時間 | 372 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 259,328 KB |
| 最終ジャッジ日時 | 2026-01-08 03:57:35 |
| 合計ジャッジ時間 | 11,035 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 TLE * 1 -- * 5 |
ソースコード
from itertools import accumulate
from collections.abc import Iterable
def accum_dp(xs: Iterable, f, op, e, init: dict, *, is_reset=True):
dp = init.copy()
for x in xs:
pp = {} if is_reset else dp.copy()
dp, pp = pp, dp
for fm_key, fm_val in pp.items():
for to_key, to_val in f(fm_key, fm_val, x):
dp[to_key] = op(dp.get(to_key, e), to_val)
return dp
def f(k, v, x):
yield k, v
yield k ^ x, v + 1
def op(a, b):
return min(a, b)
def solve():
s = 0
for a in A:
s ^= a
if s != 0: return False
if N > 5001: return True
if A.count(0) > 0: return True
init = {A[0]: 1}
dp = accum_dp(A[1:], f, op, INF, init)
res = dp.get(0, INF)
return res < N
INF = 1 << 62
N = int(input())
A = list(map(int, input().split()))
ans = solve()
if ans:
print('Yes')
else:
print('No')
norioc