結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-03 20:47:04 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 707 bytes |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 149,376 KB |
| 最終ジャッジ日時 | 2024-11-14 20:33:46 |
| 合計ジャッジ時間 | 636 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:5:1: error: [GHC-87110]
Could not load module ‘Text.Parsec’.
It is a member of the hidden package ‘parsec-3.1.17.0’.
Use -v to see a list of the files searched for.
|
5 | import Text.Parsec (parse, many, many1, eof)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:6:1: error: [GHC-87110]
Could not load module ‘Text.Parsec.String’.
It is a member of the hidden package ‘parsec-3.1.17.0’.
Use -v to see a list of the files searched for.
|
6 | import Text.Parsec.String (Parser)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:7:1: error: [GHC-87110]
Could not load module ‘Text.Parsec.Char’.
It is a member of the hidden package ‘parsec-3.1.17.0’.
Use -v to see a list of the files searched for.
|
7 | import Text.Parsec.Char (digit, char)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative ((<$>), (<|>)) import Data.List (foldl', tails, inits) import Data.Either (rights) import Text.Parsec (parse, many, many1, eof) import Text.Parsec.String (Parser) import Text.Parsec.Char (digit, char) main :: IO () main = solve <$> getLine >>= print solve :: String -> Int solve s = maximum . rights . map (parse expr "") $ zipWith (++) (tails s) (inits s) expr :: Parser Int expr = do x <- num fs <- many (plus <|> minus) eof return $ foldl' (\a f -> f a) x fs num :: Parser Int num = read <$> many1 digit plus :: Parser (Int -> Int) plus = do char '+' x <- num return (+x) minus :: Parser (Int -> Int) minus = do char '-' x <- num return (subtract x)