結果

問題 No.392 2分木をたどれ
ユーザー gemmarogemmaro
提出日時 2020-06-02 21:20:37
言語 Haskell
(9.6.2)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 7,122 ms
コンパイル使用メモリ 164,060 KB
実行使用メモリ 12,128 KB
最終ジャッジ日時 2023-08-16 03:57:06
合計ジャッジ時間 6,728 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,060 KB
testcase_01 AC 22 ms
12,080 KB
testcase_02 AC 22 ms
12,128 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 a = unlines $ reverse $ solve' a []

solve' :: [Int] -> [String] -> [String]
solve' t ss = foldl (\acc x -> solve'' x "" : acc) ss t

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