結果

問題 No.1072 A Nice XOR Pair
ユーザー mirucamiruca
提出日時 2020-06-10 16:33:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 612 ms / 2,000 ms
コード長 328 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 10,688 KB
実行使用メモリ 31,604 KB
最終ジャッジ日時 2023-09-05 12:02:45
合計ジャッジ時間 3,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,452 KB
testcase_01 AC 18 ms
8,492 KB
testcase_02 AC 18 ms
8,476 KB
testcase_03 AC 18 ms
8,612 KB
testcase_04 AC 18 ms
8,652 KB
testcase_05 AC 19 ms
8,628 KB
testcase_06 AC 24 ms
8,820 KB
testcase_07 AC 612 ms
31,604 KB
testcase_08 AC 385 ms
16,392 KB
testcase_09 AC 380 ms
16,456 KB
testcase_10 AC 376 ms
16,516 KB
testcase_11 AC 448 ms
20,052 KB
testcase_12 AC 481 ms
31,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

n, x = map(int, input().split())
A = [int(input()) for _ in range(n)]
c = Counter(A)

res = 0
if x == 0:
    for k,v in c.items():
        res += v * (v - 1) // 2
    print(res)
else:
    for k, v in c.items():
        if k ^ x in c.keys():
            res += c[k] * c[k ^ x]
    print(res // 2)
0