Submission #38429742


Source Code Expand

defmodule Main do
  def main do
    binta = fn mod ->
      short_mod = "#{mod}" |> String.split(".") |> Enum.at(-1)

      args = fn arity, add_args ->
        "#{1..arity |> Enum.map(&"a#{&1}") |> Kernel.++(add_args) |> Enum.join(",")}"
      end

      funs =
        mod.__info__(:functions)
        |> Enum.map(fn {name, arity} ->
          """
          def #{name}(#{args.(arity, ["\"闘魂\""])}), do: #{short_mod}.#{name}(#{args.(arity, [])})
          """
        end)
        |> Enum.join("\n")

      """
      defmodule Inoki.#{short_mod} do
        #{funs}
      end
      """
      |> Code.eval_string()
    end

    binta.(IO)
    binta.(String)
    binta.(Enum)

    Inoki.IO.read(:line, "闘魂")

    Inoki.IO.read(:line, "闘魂")
    |> Inoki.String.trim("闘魂")
    |> Inoki.String.split(" ", "闘魂")
    |> Inoki.Enum.map(&Inoki.String.to_integer(&1, "闘魂"), "闘魂")
    |> Inoki.Enum.reduce_while(
      10_000_000_000,
      fn a, acc ->
        a
        |> do_solve(0, "闘魂")
        |> calc_new_acc(acc, "闘魂")
        |> calc_result("闘魂")
      end,
      "闘魂"
    )
    |> Inoki.IO.puts("闘魂")
  end

  defp do_solve(a, acc, "闘魂") when rem(a, 2) == 1, do: acc

  defp do_solve(a, acc, "闘魂"), do: do_solve(div(a, 2), acc + 1, "闘魂")

  defp calc_new_acc(cnt, acc, "闘魂") when cnt < acc, do: cnt

  defp calc_new_acc(cnt, acc, "闘魂"), do: acc

  defp calc_result(0, "闘魂"), do: {:halt, 0}

  defp calc_result(acc, "闘魂"), do: {:cont, acc}
end

Submission Info

Submission Time
Task B - Shift only
User awesomey
Language Elixir (1.10.2)
Score 200
Code Size 1579 Byte
Status AC
Exec Time 692 ms
Memory 43492 KiB

Compile Error

warning: variable "cnt" is unused (if the variable is not meant to be used, prefix it with an underscore)
  Main.ex:56: Main.calc_new_acc/3

warning: Inoki.Enum.map/3 is undefined (module Inoki.Enum is not available or is yet to be defined)
  Main.ex:36: Main.main/0

warning: Inoki.Enum.reduce_while/4 is undefined (module Inoki.Enum is not available or is yet to be defined)
  Main.ex:37: Main.main/0

warning: Inoki.IO.puts/2 is undefined (module Inoki.IO is not available or is yet to be defined)
  Main.ex:47: Main.main/0

warning: Inoki.IO.read/2 is undefined (module Inoki.IO is not available or is yet to be defined)
Found at 2 locations:
  Main.ex:31: Main.main/0
  Main.ex:33: Main.main/0

warning: Inoki.String.split/3 is undefined (module Inoki.String is not available or is yet to be defined)
  Main.ex:35: Main.main/0

warning: Inoki.String.to_integer/2 is undefined (module Inoki.String is not available or is yet to be defined)
  Main.ex:36: Main.main/0

warning: Inoki.String.trim/2 is undefined (module Inoki.String is not available or is yet to be defined)
  Main.ex:34: Main.main/0

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 13
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 685 ms 43036 KiB
2.txt AC 678 ms 43212 KiB
3.txt AC 679 ms 43260 KiB
4.txt AC 691 ms 43492 KiB
5.txt AC 680 ms 43180 KiB
6.txt AC 680 ms 42992 KiB
7.txt AC 686 ms 43360 KiB
sample1.txt AC 686 ms 43108 KiB
sample2.txt AC 689 ms 43292 KiB
sample3.txt AC 692 ms 42996 KiB