結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:11:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 196 ms / 2,000 ms |
| コード長 | 775 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 140,796 KB |
| 最終ジャッジ日時 | 2025-03-20 21:13:21 |
| 合計ジャッジ時間 | 1,871 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
import sys
from collections import Counter
def main():
n, x = map(int, sys.stdin.readline().split())
a = [int(sys.stdin.readline()) for _ in range(n)]
cnt = Counter(a)
ans = 0
if x == 0:
for k in cnt:
c = cnt[k]
ans += c * (c - 1) // 2
else:
seen = set()
for k in cnt:
if k in seen:
continue
t = k ^ x
if t not in cnt:
continue
if t == k:
ans += cnt[k] * (cnt[k] - 1) // 2
seen.add(k)
else:
if k < t:
ans += cnt[k] * cnt[t]
seen.add(k)
seen.add(t)
print(ans)
if __name__ == "__main__":
main()
lam6er