結果

問題 No.1072 A Nice XOR Pair
ユーザー FromBooskaFromBooska
提出日時 2023-10-18 12:43:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 111,728 KB
最終ジャッジ日時 2023-10-18 12:43:27
合計ジャッジ時間 2,594 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,500 KB
testcase_01 AC 41 ms
53,500 KB
testcase_02 AC 42 ms
53,500 KB
testcase_03 AC 40 ms
53,500 KB
testcase_04 AC 40 ms
53,500 KB
testcase_05 AC 40 ms
53,500 KB
testcase_06 AC 71 ms
70,988 KB
testcase_07 AC 244 ms
111,728 KB
testcase_08 AC 165 ms
81,440 KB
testcase_09 AC 160 ms
81,440 KB
testcase_10 AC 165 ms
81,440 KB
testcase_11 AC 204 ms
94,296 KB
testcase_12 AC 221 ms
109,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Ai^Aj=Xということは、Ai=Aj^X
# Counter
# X==0 and or Ai==0のときは別対応必要ないみたい
# ダブルカウント避ける

N, X = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))
from collections import Counter
counted = Counter(A)

ans = 0
for i in range(N):
    counted[A[i]] -= 1
    xa = X^A[i]
    calc = counted[xa]
    ans += calc
print(ans)
0