結果
| 問題 |
No.2672 Subset Xor Sum
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2024-03-15 23:14:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 966 bytes |
| コンパイル時間 | 154 ms |
| コンパイル使用メモリ | 82,152 KB |
| 実行使用メモリ | 187,484 KB |
| 最終ジャッジ日時 | 2024-09-30 02:48:15 |
| 合計ジャッジ時間 | 7,318 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 64 WA * 2 |
ソースコード
# まず全部で0になるか、そしてどこかで0ができればYesだろう
# どこかで0になるかは、定かでないがソートして累積xor sumして同じ数字がN差でなく登場するかでどうだろう
N = int(input())
A = list(map(int, input().split()))
A.sort()
from collections import Counter, defaultdict
total = 0
for i in range(N):
total ^= A[i]
#print('total', total)
ans = 'No'
if total == 0:
if 0 in A:
ans = 'Yes'
xor_cumu = [0]
temp = 0
for a in A:
temp ^= a
xor_cumu.append(temp)
dic = defaultdict(list)
for i in range(N, -1, -1):
dic[xor_cumu[i]].append(i)
#print('xor_cumu', xor_cumu)
#print('dic', dic)
for i in range(N+1):
#print('i', i, 'dic[xor_cumu[i]][0]', dic[xor_cumu[i]][0], dic[xor_cumu[i]][0]-i<N, 'ans', ans)
if dic[xor_cumu[i]][0] != i and dic[xor_cumu[i]][0]-i<N:
ans = 'Yes'
print(ans)
FromBooska