結果

問題 No.478 一般門松列列
ユーザー atuk721atuk721
提出日時 2017-02-06 05:38:49
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 164,152 KB
実行使用メモリ 16,516 KB
最終ジャッジ日時 2023-08-25 22:52:45
合計ジャッジ時間 6,358 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
7,060 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
7,072 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
7,060 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import qualified Data.Char as C

main :: IO ()
main = do
  [n, k] <- fmap (map read . words) getLine :: IO [Int]
  let ix = [(10 ^ (n -1))..(10 ^ n - 1)]
      ix' = map (map C.digitToInt . show) ix
      result = (!! 0) . take 1 $ filter (check (n - k - 2)) ix'

  putStrLn $ if length result == 0
               then "-1"
               else foldr (\c a -> (show c) ++ " " ++ a) "" result

check :: Int -> [Int] -> Bool
check 0 (_:_:[]) = True
check _ (_:_:[]) = False
check k' (a:b:c:xs)
  | k' < 0 = False
  | isKadomatsu = check (k'-1) (b:c:xs)
  | otherwise = check k' (b:c:xs)
  where isKadomatsu = (a > b && c > b) || (a < b && c < b)
0