結果

問題 No.1072 A Nice XOR Pair
ユーザー 👑 KazunKazun
提出日時 2020-06-05 21:31:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 111,292 KB
最終ジャッジ日時 2023-08-22 14:22:50
合計ジャッジ時間 3,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,584 KB
testcase_01 AC 71 ms
71,568 KB
testcase_02 AC 71 ms
71,244 KB
testcase_03 AC 72 ms
71,108 KB
testcase_04 AC 70 ms
71,324 KB
testcase_05 AC 71 ms
71,508 KB
testcase_06 AC 93 ms
76,624 KB
testcase_07 AC 273 ms
111,292 KB
testcase_08 AC 161 ms
77,112 KB
testcase_09 AC 163 ms
77,376 KB
testcase_10 AC 167 ms
77,400 KB
testcase_11 AC 225 ms
91,108 KB
testcase_12 AC 251 ms
105,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,X=map(int,input().split())
A={}
U=set()

for i in range(N):
    a=int(input())
    U.add(a)
    if a in A:
        A[a]+=1
    else:
        A[a]=1

S=0
while U:
    x=U.pop()
    y=X^x
    if (x!=y) and (X^x in U):
        U.remove(y)
        S+=A[x]*A[y]
    if y==x:
        S+=(A[x]*(A[x]-1))//2
                      
        
                      

print(S)
0