結果

問題 No.1072 A Nice XOR Pair
ユーザー 小野寺健小野寺健
提出日時 2021-11-05 16:34:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 23,680 KB
最終ジャッジ日時 2024-04-24 00:37:38
合計ジャッジ時間 5,973 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,288 KB
testcase_01 AC 92 ms
12,288 KB
testcase_02 AC 91 ms
12,288 KB
testcase_03 AC 90 ms
12,288 KB
testcase_04 WA -
testcase_05 AC 91 ms
12,160 KB
testcase_06 AC 101 ms
12,160 KB
testcase_07 AC 1,332 ms
23,680 KB
testcase_08 AC 228 ms
17,536 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 700 ms
19,456 KB
testcase_12 AC 1,227 ms
23,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, X = gets.split(" ").map{|s| s.to_i}
a = []

N.times {
	a << gets.to_i
}

a.sort!

cnt = 0
a.uniq.each {|y|
	ymin = a.bsearch_index{|i| i >= y}
	ymax = a.bsearch_index{|i| i > y}
	ymax = N if not ymax
	ycnt = ymax - ymin
	z = y ^ X
	zmin = a.bsearch_index{|i| i >= z}
	next if not zmin
	zmax = a.bsearch_index{|i| i > z}
	zmax = N if not zmax
	zcnt = zmax - zmin
	cnt += ycnt * zcnt
}

puts cnt / 2
0