結果

問題 No.82 市松模様
ユーザー gemmarogemmaro
提出日時 2020-04-17 09:24:50
言語 Elixir
(1.16.2)
結果
AC  
実行時間 570 ms / 5,000 ms
コード長 505 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 55,520 KB
実行使用メモリ 49,876 KB
最終ジャッジ日時 2023-08-30 00:18:28
合計ジャッジ時間 7,981 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 558 ms
49,844 KB
testcase_01 AC 558 ms
49,260 KB
testcase_02 AC 557 ms
49,212 KB
testcase_03 AC 559 ms
49,756 KB
testcase_04 AC 561 ms
49,244 KB
testcase_05 AC 562 ms
49,076 KB
testcase_06 AC 570 ms
49,172 KB
testcase_07 AC 563 ms
49,232 KB
testcase_08 AC 561 ms
49,876 KB
testcase_09 AC 567 ms
49,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    IO.read(:line)
    |> String.split()
    |> solve
    |> IO.puts()
  end

  defp solve([w, h, c]) do
    d =
      cond do
        c == "B" -> "W"
        true -> "B"
      end

    0..((h |> String.to_integer()) - 1)
    |> Enum.map(fn i ->
      0..((w |> String.to_integer()) - 1)
      |> Enum.map(fn j ->
        cond do
          (i - j) |> rem(2) == 0 -> c
          true -> d
        end
      end)
      |> Enum.join()
    end)
    |> Enum.join("\n")
  end
end
0