結果
問題 | No.1072 A Nice XOR Pair |
ユーザー | 小野寺健 |
提出日時 | 2021-11-05 17:25:29 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 518 bytes |
コンパイル時間 | 60 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 90,292 KB |
最終ジャッジ日時 | 2024-04-24 01:34:11 |
合計ジャッジ時間 | 4,303 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
17,664 KB |
testcase_01 | AC | 76 ms
12,160 KB |
testcase_02 | AC | 80 ms
12,416 KB |
testcase_03 | AC | 76 ms
12,160 KB |
testcase_04 | AC | 75 ms
12,416 KB |
testcase_05 | AC | 75 ms
12,416 KB |
testcase_06 | AC | 86 ms
18,944 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
コンパイルメッセージ
Main.rb:12: warning: assigned but unused variable - i Syntax OK
ソースコード
N, X = gets.split(" ").map{|s| s.to_i} a = [] N.times { a << gets.to_i } a.sort! cnt = 0 i = 0 while a and a.length > 0 do y = a[0] ycnt = a.bsearch_index{|i| i > y} ycnt = a.length if not ycnt z = y ^ X a = a[ycnt..-1] if z == y then cnt += ycnt * (ycnt - 1) / 2 next end zmin = a.bsearch_index{|i| i >= z} next if not zmin zmax = a.bsearch_index{|i| i > z} zmax = a.length if not zmax zcnt = zmax - zmin cnt += ycnt * zcnt break if zmax == a.length a = a[0, zmin] + a[zmax..-1] end puts cnt