結果
| 問題 |
No.457 (^^*)
|
| コンテスト | |
| ユーザー |
okaduki
|
| 提出日時 | 2016-12-15 01:56:57 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 3,393 ms |
| コンパイル使用メモリ | 181,660 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 08:12:40 |
| 合計ジャッジ時間 | 3,693 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
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 Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
solvel :: B.ByteString -> Integer
solvel s = calcl (0,0,0) 0 s 0
calcl (n1,n2,n3) num s acc =
if s == B.empty then acc
else case (B.head s) of
'(' -> calcl (n1,n2,n3+1) num bs acc
')' -> calcl (n1,n2,n3) num bs (acc + num)
'^' -> calcl (n1+n2,n3,0) num bs acc
_ -> calcl (0,n2,n3) (num+n1) bs acc
where bs = B.tail s
rev = B.map (\c -> case c of
'(' -> ')'
')' -> '('
_ -> c) . B.reverse
main = do
s <- B.getLine
let rs = rev s
printf "%d %d\n" (solvel s) (solvel rs)
okaduki