結果

問題 No.1072 A Nice XOR Pair
ユーザー lloyzlloyz
提出日時 2022-06-04 17:14:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 678 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 64,380 KB
最終ジャッジ日時 2023-10-21 02:47:16
合計ジャッジ時間 4,827 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,024 KB
testcase_01 AC 29 ms
10,024 KB
testcase_02 AC 29 ms
10,024 KB
testcase_03 AC 30 ms
10,024 KB
testcase_04 AC 30 ms
10,024 KB
testcase_05 AC 30 ms
10,024 KB
testcase_06 AC 37 ms
10,340 KB
testcase_07 AC 628 ms
46,164 KB
testcase_08 AC 411 ms
17,952 KB
testcase_09 AC 415 ms
17,952 KB
testcase_10 AC 416 ms
17,724 KB
testcase_11 AC 517 ms
28,376 KB
testcase_12 AC 678 ms
64,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

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

counter = Counter(A)
seen = set()
ans = 0
for val, cnt in counter.items():
    if val in seen:
        continue
    res = x ^ val
    if res == val:
        ans += cnt * (cnt - 1) // 2
    else:
        ans += cnt * counter[res]
    seen.add(val)
    seen.add(res)
print(ans)
0