結果

問題 No.632 穴埋め門松列
コンテスト
ユーザー norioc
提出日時 2024-08-14 21:35:34
言語 Elixir
(1.19.5)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 319 ms / 1,000 ms
コード長 665 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,011 ms
コンパイル使用メモリ 72,408 KB
実行使用メモリ 63,360 KB
最終ジャッジ日時 2026-04-03 21:10:14
合計ジャッジ時間 3,627 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

defmodule Main do
  def input, do: IO.read(:line) |> String.trim
  def ii, do: input() |> String.to_integer
  def li, do: input() |> String.split |> Enum.map(&String.to_integer/1)
  def yn(b), do: IO.puts(if b, do: "Yes", else: "No")

  def main do
    s = input()

    for x <- ["1", "4"] do
      t = String.replace(s, "?", x)
      [a, b, c] = t |> String.split |> Enum.map(&String.to_integer/1)
      if is_kadomatu(a, b, c), do: x, else: ""
    end
    |> Enum.join
    |> IO.puts
  end

  def is_kadomatu(a, b, c) do
    cond do
      a == b or b == c or c == a -> false
      true ->
        [_, x, _] = Enum.sort([a, b, c])
        b != x
    end
  end
end
0