結果

問題 No.1072 A Nice XOR Pair
ユーザー umashi-pan-tnokk093numashi-pan-tnokk093n
提出日時 2020-06-06 13:01:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,719 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 41,468 KB
最終ジャッジ日時 2023-08-25 00:34:49
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,100 KB
testcase_01 AC 15 ms
8,012 KB
testcase_02 AC 15 ms
8,004 KB
testcase_03 AC 17 ms
8,056 KB
testcase_04 AC 16 ms
8,136 KB
testcase_05 AC 16 ms
7,952 KB
testcase_06 AC 21 ms
8,612 KB
testcase_07 AC 632 ms
41,352 KB
testcase_08 AC 461 ms
16,216 KB
testcase_09 AC 1,719 ms
19,152 KB
testcase_10 AC 465 ms
16,424 KB
testcase_11 AC 537 ms
25,496 KB
testcase_12 AC 579 ms
41,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n,x=map(int,input().split())
a=[]
b=dict()
for i in range(n):
    num=int(input())
    a.append(num)
    if num not in b:
        b[num]=1
    else:
        b[num]+=1

c=list(set(a))
#print(b)
#print(c)
ans=0
if x==0:
    def combinations_count(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    for i in b.values():
        ans+=combinations_count(i,2)
    
else:
    for i in c:
        m=x^i
        if m in b:
            ans+=b[m]*b[i]
    ans=ans//2
print(ans)
0