結果

問題 No.1072 A Nice XOR Pair
ユーザー simansiman
提出日時 2020-10-07 18:41:43
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 337 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 46,944 KB
最終ジャッジ日時 2023-09-27 09:21:29
合計ジャッジ時間 4,206 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,108 KB
testcase_01 AC 75 ms
15,264 KB
testcase_02 AC 73 ms
15,260 KB
testcase_03 AC 71 ms
15,104 KB
testcase_04 WA -
testcase_05 AC 75 ms
15,128 KB
testcase_06 AC 75 ms
15,360 KB
testcase_07 AC 329 ms
38,488 KB
testcase_08 AC 198 ms
19,044 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 250 ms
26,868 KB
testcase_12 AC 356 ms
46,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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
0