結果
問題 |
No.2672 Subset Xor Sum
|
ユーザー |
![]() |
提出日時 | 2024-03-16 07:32:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,001 bytes |
コンパイル時間 | 211 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 187,908 KB |
最終ジャッジ日時 | 2024-09-30 03:53:07 |
合計ジャッジ時間 | 6,813 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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' if N>5001: 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)