結果

問題 No.1072 A Nice XOR Pair
ユーザー dangodango
提出日時 2023-07-06 21:47:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 86,472 KB
実行使用メモリ 89,692 KB
最終ジャッジ日時 2023-09-27 22:45:38
合計ジャッジ時間 5,153 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,108 KB
testcase_01 AC 73 ms
71,020 KB
testcase_02 AC 74 ms
71,304 KB
testcase_03 AC 75 ms
71,336 KB
testcase_04 AC 75 ms
71,084 KB
testcase_05 AC 75 ms
70,992 KB
testcase_06 AC 114 ms
76,684 KB
testcase_07 AC 224 ms
87,928 KB
testcase_08 AC 191 ms
87,080 KB
testcase_09 AC 181 ms
87,056 KB
testcase_10 AC 212 ms
87,968 KB
testcase_11 AC 237 ms
89,692 KB
testcase_12 AC 242 ms
89,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = map(int, input().split())
a = []
for _ in range(n):
  a.append(int(input()))
a = sorted(a)
b = sorted([i ^ x for i in a])
i = j = c = 0
while i < n and j < n:
    if a[i] < b[j]:
        i += 1
    elif a[i] > b[j]:
        j += 1
    else:
        i0 = i
        while i < n and a[i] == a[i0]:
            i += 1
        j0 = j
        while j < n and b[j] == b[j0]:
            j += 1
        c += (i - i0) * (j - j0 - (x == 0))
print(c // 2)
0