結果
問題 | No.457 (^^*) |
ユーザー | okaduki |
提出日時 | 2016-12-15 00:59:19 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 1,301 ms / 2,000 ms |
コード長 | 1,145 bytes |
コンパイル時間 | 4,106 ms |
コンパイル使用メモリ | 181,108 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-05-07 14:41:08 |
合計ジャッジ時間 | 10,519 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 5 ms
6,400 KB |
testcase_11 | AC | 8 ms
8,320 KB |
testcase_12 | AC | 834 ms
9,728 KB |
testcase_13 | AC | 631 ms
8,832 KB |
testcase_14 | AC | 1,292 ms
9,984 KB |
testcase_15 | AC | 832 ms
9,856 KB |
testcase_16 | AC | 1,301 ms
10,240 KB |
testcase_17 | AC | 626 ms
8,576 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:17:31: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 17 | 3 -> head rs | ^^^^ Main.hs:18:36: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 18 | 0 -> sub (tail rs) (B.tail s) | ^^^^ Main.hs:20:36: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 20 | _ -> sub (tail rs) (B.tail s) | ^^^^ Main.hs:23:31: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 23 | calcacc = B.foldr (\c acc -> (head acc + if c == ')' then 1 else 0):acc) [0] | ^^^^ [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 calcr :: [Integer] -> B.ByteString -> Integer -> Integer calcr (r:rs) s acc = if s == B.empty then acc else calcr rs bs (if B.head s == '(' then acc + sub rs bs 0 else acc) where bs = B.tail s sub rs s lv = if s == B.empty then 0 else case lv of 3 -> head rs 0 -> sub (tail rs) (B.tail s) (if B.head s == '*' then lv+1 else lv) _ -> sub (tail rs) (B.tail s) (if B.head s == '^' then lv+1 else lv) calcacc = B.foldr (\c acc -> (head acc + if c == ')' then 1 else 0):acc) [0] rev = B.map (\c -> case c of '(' -> ')' ')' -> '(' _ -> c) . B.reverse main = do s <- B.getLine let rs = rev s printf "%d %d\n" (calcr (calcacc rs) rs 0) (calcr (calcacc s) s 0)