結果
| 問題 | No.457 (^^*) |
| コンテスト | |
| ユーザー |
okaduki
|
| 提出日時 | 2016-12-15 01:56:57 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 724 bytes |
| 記録 | |
| コンパイル時間 | 4,362 ms |
| コンパイル使用メモリ | 209,092 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-24 00:00:32 |
| 合計ジャッジ時間 | 5,884 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/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