結果
問題 | No.334 門松ゲーム |
ユーザー | ducktail |
提出日時 | 2018-08-10 21:46:13 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 9 ms / 2,000 ms |
コード長 | 1,207 bytes |
コンパイル時間 | 9,636 ms |
コンパイル使用メモリ | 204,800 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-09-23 05:56:37 |
合計ジャッジ時間 | 10,787 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 8 ms
8,192 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 6 ms
8,192 KB |
testcase_07 | AC | 6 ms
8,064 KB |
testcase_08 | AC | 5 ms
8,192 KB |
testcase_09 | AC | 5 ms
7,680 KB |
testcase_10 | AC | 9 ms
8,064 KB |
testcase_11 | AC | 4 ms
7,552 KB |
testcase_12 | AC | 3 ms
6,400 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 6 ms
8,192 KB |
testcase_15 | AC | 6 ms
8,320 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:15:35: 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." | 15 | | otherwise = Just (head rs) | ^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>), (<*>)) import Control.Monad (guard) import Data.Vector.Unboxed (Vector, (!), (//)) import qualified Data.Vector.Unboxed as V import Data.Maybe (catMaybes) main :: IO () main = solve <$> readLn <*> (V.fromList <$> map read <$> words <$> getLine) >>= putStrLn solve :: Int -> Vector Int -> String solve n ss = maybe "-1" (\(a, b, c) -> unwords . map show $ [a, b, c]) $ f n ss where f :: Int -> Vector Int -> Maybe (Int, Int, Int) f m v | null ls = Nothing | null rs = Nothing | otherwise = Just (head rs) where ls = do i <- [0..m-3] j <- [i+1..m-2] k <- [j+1..m-1] let ti = v ! i let tj = v ! j let tk = v ! k guard $ ti > 0 && tj > 0 && tk > 0 guard $ ti /= tk && (ti - tj) * (tk - tj) > 0 return (i, j, k) rs = catMaybes $ do (i, j, k) <- ls let nv = v // [(i,0),(j,0),(k,0)] case f m nv of Nothing -> return $ Just (i, j, k) Just _ -> return Nothing