結果

問題 No.1072 A Nice XOR Pair
ユーザー 小野寺健小野寺健
提出日時 2021-11-06 08:17:50
言語 Ruby
(3.3.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 296 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 24,540 KB
最終ジャッジ日時 2024-04-24 17:59:01
合計ジャッジ時間 3,760 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
12,032 KB
testcase_01 AC 90 ms
12,288 KB
testcase_02 AC 92 ms
12,288 KB
testcase_03 AC 89 ms
12,288 KB
testcase_04 AC 92 ms
12,288 KB
testcase_05 AC 90 ms
12,160 KB
testcase_06 AC 94 ms
12,160 KB
testcase_07 AC 344 ms
24,540 KB
testcase_08 AC 216 ms
12,160 KB
testcase_09 AC 212 ms
12,288 KB
testcase_10 AC 218 ms
12,288 KB
testcase_11 AC 278 ms
18,688 KB
testcase_12 AC 336 ms
24,092 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, X = gets.split(" ").map{|s| s.to_i}
a = Hash.new(0)

N.times {
	a[gets.to_i] += 1
}

cnt = 0
a.keys.each {|k|
	next if not a.has_key?(k)
	vk = a.delete(k)
	x = k ^ X
	if x == k then
		cnt += vk * (vk - 1) / 2
		next
	end
	next if not a.has_key?(x)
	vx = a.delete(x)
	cnt += vk * vx
}

puts cnt
0