結果

問題 No.397 NO MORE KADOMATSU
ユーザー aimyaimy
提出日時 2017-04-29 15:20:22
言語 Haskell
(9.8.2)
結果
RE  
実行時間 -
コード長 566 bytes
コンパイル時間 5,274 ms
コンパイル使用メモリ 171,392 KB
実行使用メモリ 25,476 KB
平均クエリ数 936.56
最終ジャッジ日時 2024-07-16 12:51:41
合計ジャッジ時間 8,147 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,836 KB
testcase_01 RE -
testcase_02 AC 23 ms
24,836 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 25 ms
24,580 KB
testcase_10 AC 62 ms
25,220 KB
testcase_11 AC 28 ms
25,476 KB
testcase_12 AC 44 ms
25,476 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 24 ms
24,952 KB
testcase_17 AC 23 ms
25,208 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:23:27: 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."
   |
23 |   ikado ixs = fst $ fst $ head $ filter (\(ix1,ix2) -> snd ix1 > snd ix2) $ zip ixs (tail ixs)
   |                           ^^^^

Main.hs:23:86: warning: [GHC-63394] [-Wx-partial]
    In the use of ‘tail’
    (imported from Data.List, but defined in GHC.List):
    "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty."
   |
23 |   ikado ixs = fst $ fst $ head $ filter (\(ix1,ix2) -> snd ix1 > snd ix2) $ zip ixs (tail ixs)
   |                                                                                      ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List
import Data.Ord
import System.IO

replace i xs = xs1 ++ (x':x:xs2)
 where (xs1,(x:x':xs2)) = splitAt i xs

main = do
 getLine
 as <- map read . words <$> getLine
 let output = nmk as
 print (length output)
 mapM_ (putStrLn . unwords . map show) output
 hFlush stdout
 getLine

nmk :: [Int] -> [[Int]]
nmk xs = nmk' [] xs
 where
  nmk' acc xs'
   | sort xs' == xs' = acc
   | otherwise = let i = ikado (zip [0..] xs') in nmk' ([i,i+1]:acc) (replace i xs')
  ikado ixs = fst $ fst $ head $ filter (\(ix1,ix2) -> snd ix1 > snd ix2) $ zip ixs (tail ixs)
0