結果

問題 No.1072 A Nice XOR Pair
ユーザー ntuda
提出日時 2024-01-27 16:39:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,116 KB
実行使用メモリ 108,852 KB
最終ジャッジ日時 2024-09-28 09:41:59
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

N, X = map(int, input().split())
A = [int(input()) for _ in range(N)]

from collections import defaultdict
dic = defaultdict(int)
for a in A:
    dic[a] += 1

ans = 0
if X == 0:
    for k,v in dic.items():
        ans += v * (v-1) // 2
    print(ans)
    exit()

for k, v in dic.items():
    if k ^ X in dic:
        ans += dic[k] * dic[k ^ X]
print(ans // 2)
0