結果

問題 No.1072 A Nice XOR Pair
ユーザー 👑 KazunKazun
提出日時 2020-06-05 21:31:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 106,640 KB
最終ジャッジ日時 2024-05-09 20:07:07
合計ジャッジ時間 2,713 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
51,584 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 43 ms
51,968 KB
testcase_03 AC 43 ms
52,096 KB
testcase_04 AC 42 ms
52,096 KB
testcase_05 AC 42 ms
52,096 KB
testcase_06 AC 73 ms
67,328 KB
testcase_07 AC 321 ms
106,640 KB
testcase_08 AC 155 ms
76,164 KB
testcase_09 AC 155 ms
76,268 KB
testcase_10 AC 159 ms
76,160 KB
testcase_11 AC 265 ms
89,660 KB
testcase_12 AC 293 ms
105,312 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