結果
問題 | No.204 ゴールデン・ウィーク(2) |
ユーザー | aimy |
提出日時 | 2017-04-30 11:05:21 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 2,010 ms |
コンパイル使用メモリ | 172,928 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 23:30:34 |
合計ジャッジ時間 | 3,325 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,944 KB |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 1 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 1 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 1 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | RE | - |
testcase_37 | AC | 1 ms
6,940 KB |
testcase_38 | AC | 1 ms
6,940 KB |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 1 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 1 ms
6,940 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 1 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
testcase_48 | AC | 2 ms
6,944 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:13:41: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Data.List, 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." | 13 | chead = maximum $ map length $ filter head $ group $ replicate d True ++ dropWhile not cs | ^^^^ Main.hs:14:41: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Data.List, 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." | 14 | clast = maximum $ map length $ filter head $ group $ (reverse . dropWhile not . reverse) cs ++ replicate d True | ^^^^ Main.hs:21:50: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Data.List, 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." | 21 | return $ maximum $ (0:) $ map length $ filter head $ group cs' | ^^^^ [2 of 2] Linking a.out
ソースコード
import Data.Char import Data.List import Control.Monad main = do d <- readLn cs <- map (\c -> if c=='o' then True else False) . filter isAlpha <$> getContents print (gw2 d cs) gw2 :: Int -> [Bool] -> Int gw2 d cs = maximum [chead, clast, maximum (0:cinter)] where chead = maximum $ map length $ filter head $ group $ replicate d True ++ dropWhile not cs clast = maximum $ map length $ filter head $ group $ (reverse . dropWhile not . reverse) cs ++ replicate d True cinter = do i <- [0 .. 14-d] m <- [1..d] let pat = replicate i False ++ replicate m True ++ replicate (14-(m+i)) False let cs' = zipWith (||) pat cs guard (length (filter id cs') == length (filter id cs) + m) return $ maximum $ (0:) $ map length $ filter head $ group cs'