結果

問題 No.850 企業コンテスト2位
ユーザー letrangerjpletrangerjp
提出日時 2019-07-05 23:10:09
言語 Ruby
(3.3.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 11,528 KB
実行使用メモリ 31,400 KB
平均クエリ数 200.11
最終ジャッジ日時 2023-09-23 17:39:19
合計ジャッジ時間 5,291 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
30,776 KB
testcase_01 AC 107 ms
31,356 KB
testcase_02 AC 105 ms
30,656 KB
testcase_03 AC 106 ms
30,940 KB
testcase_04 AC 104 ms
31,056 KB
testcase_05 AC 105 ms
30,824 KB
testcase_06 AC 106 ms
31,400 KB
testcase_07 AC 110 ms
30,868 KB
testcase_08 AC 114 ms
30,704 KB
testcase_09 AC 113 ms
30,940 KB
testcase_10 AC 122 ms
30,828 KB
testcase_11 AC 121 ms
30,892 KB
testcase_12 AC 122 ms
31,080 KB
testcase_13 AC 122 ms
30,960 KB
testcase_14 AC 121 ms
31,132 KB
testcase_15 AC 122 ms
30,836 KB
testcase_16 AC 119 ms
30,920 KB
testcase_17 AC 120 ms
31,232 KB
testcase_18 AC 118 ms
31,324 KB
testcase_19 AC 117 ms
31,036 KB
testcase_20 AC 118 ms
30,932 KB
testcase_21 AC 120 ms
30,728 KB
testcase_22 AC 119 ms
31,220 KB
testcase_23 AC 119 ms
31,308 KB
testcase_24 AC 120 ms
31,176 KB
testcase_25 AC 119 ms
30,996 KB
testcase_26 AC 121 ms
31,160 KB
testcase_27 AC 106 ms
30,956 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

$>.sync = true

N = gets.to_i
$res = Hash.new []

def f(a)
  while a.size > 1
    new_a = []
    a.each_slice(2){|x, y|
      if y.nil?
        new_a << x
        next
      end
      puts"? #{x} #{y}"
      z = gets.to_i
      new_a << z
      if z == x
        $res[x] += [y]
      else
        $res[y] += [x]
      end
    }
    a = new_a
  end
  a[0]
end

first = f([*1..N])
second = f($res[first])
puts "! #{second}"
0