結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2020-10-07 18:42:55 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 371 ms / 2,000 ms |
| コード長 | 341 bytes |
| コンパイル時間 | 38 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 47,388 KB |
| 最終ジャッジ日時 | 2024-07-20 03:30:07 |
| 合計ジャッジ時間 | 2,973 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
コンパイルメッセージ
Syntax OK
ソースコード
N, X = gets.split.map(&:to_i)
A = N.times.map { gets.to_i }
checked = Hash.new(false)
C = A.tally
C.default = 0
ans = 0
A.uniq.each do |a|
next if checked[a]
checked[a] = true
y = X ^ a
checked[y] = true
cnt = C[y]
next if cnt == 0
if a == y
ans += cnt * (cnt - 1) / 2
else
ans += cnt * C[a]
end
end
puts ans
siman