結果

問題 No.397 NO MORE KADOMATSU
ユーザー aimyaimy
提出日時 2017-04-29 15:20:22
言語 Haskell
(9.8.2)
結果
RE  
実行時間 -
コード長 566 bytes
コンパイル時間 3,561 ms
コンパイル使用メモリ 161,652 KB
実行使用メモリ 27,796 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-23 13:14:41
合計ジャッジ時間 4,817 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
23,388 KB
testcase_01 RE -
testcase_02 AC 25 ms
23,796 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 23 ms
23,676 KB
testcase_10 AC 63 ms
27,592 KB
testcase_11 AC 24 ms
23,856 KB
testcase_12 AC 43 ms
27,356 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 22 ms
24,012 KB
testcase_17 AC 23 ms
24,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 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