結果

問題 No.934 Explosive energy drink
ユーザー gemmarogemmaro
提出日時 2020-04-26 15:26:25
言語 Elixir
(1.16.2)
結果
RE  
実行時間 -
コード長 665 bytes
コンパイル時間 1,084 ms
コンパイル使用メモリ 55,792 KB
実行使用メモリ 71,048 KB
平均クエリ数 1315.42
最終ジャッジ日時 2023-09-24 03:21:23
合計ジャッジ時間 21,053 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 486 ms
65,460 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 486 ms
65,392 KB
testcase_10 AC 489 ms
65,768 KB
testcase_11 AC 498 ms
66,056 KB
testcase_12 AC 515 ms
66,644 KB
testcase_13 AC 550 ms
65,216 KB
testcase_14 AC 494 ms
65,312 KB
testcase_15 AC 620 ms
65,876 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 654 ms
65,896 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)
    |> String.trim()
    |> String.to_integer()
    |> interact()
    |> IO.puts()
  end

  def interact(n) do
    interact_rec(1..n |> Enum.to_list())
  end

  def interact_rec(r) do
    search_unnecessary(0..((r |> length) - 1) |> Enum.to_list, r)
  end

  def search_unnecessary([], r) do
    "! #{r |> length}\n#{r |> Enum.join(" ")}\n"
  end

  def search_unnecessary([h | t], r) do
    s = r |> List.delete_at(h)

    cond do
      IO.gets("? #{(r |> length) - 1}\n#{s |> Enum.join(" ")}\n") |> String.trim() == "1" ->
        interact_rec(s)

      true ->
        search_unnecessary(t, r)
    end
  end
end
0