結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-09 14:41:29 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 774 ms / 2,000 ms |
| コード長 | 458 bytes |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 50,016 KB |
| 最終ジャッジ日時 | 2024-12-15 05:51:28 |
| 合計ジャッジ時間 | 5,550 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
from collections import defaultdict
n, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
ans = 0
if x == 0:
c = defaultdict(int)
for i in range(n):
c[a[i]] += 1
for i, m in c.items():
ans += m*(m-1)//2
print(ans)
else:
c1 = defaultdict(int)
c2 = defaultdict(int)
for i in range(n):
c1[a[i]] += 1
c2[a[i]^x] += 1
for i, m in c1.items():
ans += m*c2[i]
print(ans//2)