結果

問題 No.457 (^^*)
ユーザー momen999momen999
提出日時 2017-05-13 19:20:29
言語 Haskell
(9.6.2)
結果
TLE  
実行時間 -
コード長 954 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 165,080 KB
実行使用メモリ 16,020 KB
最終ジャッジ日時 2023-10-13 16:18:45
合計ジャッジ時間 5,815 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,028 KB
testcase_01 AC 2 ms
6,660 KB
testcase_02 AC 2 ms
6,560 KB
testcase_03 AC 2 ms
6,584 KB
testcase_04 AC 3 ms
6,560 KB
testcase_05 AC 2 ms
6,552 KB
testcase_06 AC 3 ms
6,968 KB
testcase_07 AC 4 ms
7,816 KB
testcase_08 AC 7 ms
9,956 KB
testcase_09 AC 13 ms
10,796 KB
testcase_10 AC 43 ms
10,904 KB
testcase_11 AC 143 ms
11,256 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

breakLastRParenthesis xs = reverse $ snd $ break (== ')') $ reverse xs
breakHeadLParenthesis xs = snd $ break (== '(') xs

solve xs = [show (hidarimuki xs), show (migimuki xs)]

hidarimuki :: String -> Int
hidarimuki [] = 0
hidarimuki (x:xs) = iter xs + hidarimuki (breakHeadLParenthesis xs)
    where
        iter cs
            | ws == ""                              = 0
            | star == ""                            = iter (hat ++ tail ws)
            | (length . filter (== '^')) hat < 2    = iter (hat ++ tail star ++ ws)
            | otherwise                             = (length . filter (== ')')) ws
            where
                (w, ws) = break (== ')') cs
                (hat, star) = break (== '*') w

migimuki :: String -> Int
migimuki xs = hidarimuki $ reverse $ map (\x -> if x == ')' then '(' else if x == '(' then ')' else x) xs

main = getLine >>= putStrLn . unwords . solve . breakLastRParenthesis . breakHeadLParenthesis
0