結果

問題 No.729 文字swap
ユーザー gemmarogemmaro
提出日時 2020-04-10 07:09:54
言語 Elixir
(1.16.2)
結果
AC  
実行時間 654 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 55,248 KB
実行使用メモリ 50,196 KB
最終ジャッジ日時 2023-08-30 00:03:31
合計ジャッジ時間 11,574 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 618 ms
49,120 KB
testcase_01 AC 613 ms
49,900 KB
testcase_02 AC 609 ms
49,860 KB
testcase_03 AC 613 ms
49,312 KB
testcase_04 AC 612 ms
49,240 KB
testcase_05 AC 624 ms
49,852 KB
testcase_06 AC 627 ms
49,404 KB
testcase_07 AC 624 ms
49,188 KB
testcase_08 AC 621 ms
49,336 KB
testcase_09 AC 621 ms
50,196 KB
testcase_10 AC 611 ms
49,220 KB
testcase_11 AC 625 ms
49,728 KB
testcase_12 AC 654 ms
49,272 KB
testcase_13 AC 629 ms
49,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
  def main do
    s =
      IO.gets("")
      |> String.trim()
      |> String.to_charlist()

    [i, j] =
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&(String.to_integer(&1)))

    s_i = Enum.at(s, i)
    s_j = Enum.at(s, j)

    s
    |> List.replace_at(i, s_j)
    |> List.replace_at(j, s_i)
    |> IO.puts()
  end
end
0