結果

問題 No.457 (^^*)
ユーザー ducktailducktail
提出日時 2018-08-22 15:53:31
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 752 bytes
コンパイル時間 4,505 ms
コンパイル使用メモリ 165,052 KB
実行使用メモリ 817,184 KB
最終ジャッジ日時 2023-08-25 19:07:19
合計ジャッジ時間 10,955 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,588 KB
testcase_01 AC 2 ms
6,616 KB
testcase_02 AC 2 ms
6,576 KB
testcase_03 AC 2 ms
6,652 KB
testcase_04 AC 3 ms
6,580 KB
testcase_05 AC 2 ms
6,580 KB
testcase_06 AC 3 ms
6,620 KB
testcase_07 AC 5 ms
8,428 KB
testcase_08 AC 23 ms
15,064 KB
testcase_09 AC 83 ms
38,832 KB
testcase_10 AC 703 ms
214,596 KB
testcase_11 MLE -
testcase_12 -- -
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 #

import Control.Applicative
import Data.List

main :: IO ()
main = solve <$> getLine >>= putStrLn

solve :: String -> String
solve xs = f $ foldl' count (0,0) (tails xs)
  where f (x, y) = unwords . map show $ [x, y]
          
data Face = L0 | L1 | L2 | L3 | R0 | R1 | R2 | R3

left L0 '^' = L1
left L1 '^' = L2
left L2 '*' = L3
left s _ = s

right R0 '*' = R1
right R1 '^' = R2
right R2 '^' = R3
right s _ = s

point L3 = 1
point R3 = 1
point s = 0

count :: (Int, Int) -> String -> (Int, Int)
count (l, r) ('(':xs) = let (x,y,_,_) = foldl' f (l, r, L0, R0) xs in (x, y)
  where f (cl, cr, sl, sr) c | c == ')' = (cl + point sl, cr + point sr, sl, sr)
                             | otherwise = (cl, cr, left sl c, right sr c)
count (l, r) _ = (l, r)
0