結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-22 15:53:31 |
| 言語 | Haskell (9.10.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 752 bytes |
| コンパイル時間 | 4,286 ms |
| コンパイル使用メモリ | 175,240 KB |
| 実行使用メモリ | 820,640 KB |
| 最終ジャッジ日時 | 2024-12-24 05:04:23 |
| 合計ジャッジ時間 | 20,491 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 TLE * 5 MLE * 2 |
コンパイルメッセージ
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
ソースコード
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)