結果

問題 No.1020 Reverse
コンテスト
ユーザー gemmaro
提出日時 2020-04-21 22:23:59
言語 Elixir
(1.20.4)
コンパイル:
elixirc _filename_
実行:
elixir -e Main.main
結果
AC  
実行時間 373 ms / 2,000 ms
+ 138µs
コード長 382 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 485 ms
コンパイル使用メモリ 77,768 KB
実行使用メモリ 87,920 KB
最終ジャッジ日時 2026-10-09 20:14:14
合計ジャッジ時間 8,425 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

defmodule Main do
  def main do
    [n, k] =
      IO.read(:line)
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)

    IO.read(:line)
    |> String.trim()
    |> solve(n, k)
    |> IO.puts()
  end

  def solve(s, n, k) do
    {a, b} = s |> String.split_at(k - 1)
    b <> if (n - k) |> rem(2) == 0, do: a |> String.reverse(), else: a
  end
end
0