結果

問題 No.1072 A Nice XOR Pair
ユーザー k-ish0212
提出日時 2020-06-05 22:55:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 812 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 41,356 KB
最終ジャッジ日時 2024-12-17 17:15:55
合計ジャッジ時間 4,788 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

n,x = map(int, input().split())
a = [int(input()) for _ in range(n)]
# print(a)
a.sort()
ans = 0
d = {}
for i in a:
    tmp = str(i)
    if tmp not in d:
        d[tmp] = 1
    else:
        d[tmp] += 1
# print(d)
if x != 0:
    for i in d:
        tmp = str(int(i) ^ x)
        # print(tmp)
        if tmp in d:
            ans += d[i] * d[tmp]
            d[tmp] = 0
else:
    for i in d:
        if d[i] >= 2:
            ans += int(d[i]*(d[i]-1)/2)
# print(d)
print(ans)
0