結果
| 問題 |
No.1240 Or Sum of Xor Pair
|
| コンテスト | |
| ユーザー |
👑 tatyam
|
| 提出日時 | 2020-08-23 21:59:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 833 bytes |
| コンパイル時間 | 254 ms |
| コンパイル使用メモリ | 82,032 KB |
| 実行使用メモリ | 107,852 KB |
| 最終ジャッジ日時 | 2024-06-22 07:05:05 |
| 合計ジャッジ時間 | 4,732 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 29 |
ソースコード
import sys
input = sys.stdin.readline
def fwht(a):
n = len(a)
j = 1
while j < n:
for i in range(0, n):
if i & j == 0:
a[i], a[i | j] = a[i] + a[i | j], a[i] - a[i | j]
j <<= 1
return a
def ifwht(a):
n = len(a)
j = 1
while j < n:
for i in range(0, n):
if i & j == 0:
a[i], a[i | j] = (a[i] + a[i | j]) >> 1, (a[i] - a[i | j]) >> 1
j <<= 1
return a
n, x = map(int, input().split())
assert 2 <= n <= 200000
assert 1 <= x <= 2**18
a = [*map(int, input().split())]
assert len(a) == n
for i in a:
assert 0 <= i < 2**18
cnt = [0] * 2**18
for i in a:
cnt[i] += 1
# XOR 畳み込み
fwht(cnt)
for i in range(2**18):
cnt[i] **= 2
ifwht(cnt)
ans = 0
for i in range(x):
ans += cnt[i] // 2 * i
print(ans)
tatyam