結果
| 問題 |
No.1072 A Nice XOR Pair
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2020-10-07 18:41:43 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 337 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 47,272 KB |
| 最終ジャッジ日時 | 2024-07-20 03:30:03 |
| 合計ジャッジ時間 | 3,946 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 3 |
コンパイルメッセージ
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)
else
ans += cnt * C[a]
end
end
puts ans
siman