結果
問題 |
No.729 文字swap
|
ユーザー |
|
提出日時 | 2019-08-30 15:58:13 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 407 bytes |
コンパイル時間 | 6,128 ms |
コンパイル使用メモリ | 172,544 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 11:47:57 |
合計ジャッジ時間 | 5,958 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
main = do s <- getLine (i, j) <- readint2 putStrLn (swap s i j) swap s i j = f s 0 where x = s !! i y = s !! j f s k = case s of "" -> "" (c:cs) | i == k -> y : f cs (k+1) (c:cs) | j == k -> x : f cs (k+1) (c:cs) -> c : f cs (k+1) readint2 :: IO (Int, Int) readint2 = do s <- map read . words <$> getLine return (s !! 0, s !! 1)