結果
問題 | No.334 門松ゲーム |
ユーザー | ducktail |
提出日時 | 2018-08-10 21:46:13 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 1,207 bytes |
コンパイル時間 | 7,311 ms |
コンパイル使用メモリ | 195,220 KB |
実行使用メモリ | 9,632 KB |
最終ジャッジ日時 | 2023-10-24 13:35:09 |
合計ジャッジ時間 | 8,639 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,420 KB |
testcase_01 | AC | 3 ms
5,392 KB |
testcase_02 | AC | 8 ms
9,624 KB |
testcase_03 | AC | 2 ms
5,384 KB |
testcase_04 | AC | 2 ms
5,388 KB |
testcase_05 | AC | 3 ms
5,488 KB |
testcase_06 | AC | 7 ms
9,592 KB |
testcase_07 | AC | 6 ms
9,608 KB |
testcase_08 | AC | 5 ms
9,588 KB |
testcase_09 | AC | 5 ms
9,008 KB |
testcase_10 | AC | 12 ms
9,632 KB |
testcase_11 | AC | 4 ms
9,016 KB |
testcase_12 | AC | 4 ms
7,628 KB |
testcase_13 | AC | 3 ms
6,508 KB |
testcase_14 | AC | 6 ms
9,612 KB |
testcase_15 | AC | 6 ms
9,596 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [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