結果

問題 No.392 2分木をたどれ
ユーザー gemmarogemmaro
提出日時 2020-06-02 21:28:35
言語 Haskell
(9.6.2)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 4,839 ms
コンパイル使用メモリ 163,320 KB
実行使用メモリ 12,136 KB
最終ジャッジ日時 2023-08-16 04:13:30
合計ジャッジ時間 4,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,028 KB
testcase_01 AC 21 ms
12,136 KB
testcase_02 AC 22 ms
12,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import           Control.Monad as M

main :: IO ()
main = do m <- readLn
          a <- M.replicateM m readLn
          putStr $ solve a

solve :: [Int] -> String
solve = unlines . reverse . foldl (\acc x -> solve' x "" : acc) []
    where solve' :: Int -> String -> String
          solve' 0 x = x
          solve' n x | n `mod` 2 == 0 = solve' ((n `div` 2) - 1) ( 'R' : x )
                     | otherwise      = solve' ((n - 1) `div` 2) ( 'L' : x )
0