結果

問題 No.397 NO MORE KADOMATSU
ユーザー aimyaimy
提出日時 2017-04-29 15:26:57
言語 Haskell
(9.8.2)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 161,528 KB
実行使用メモリ 27,812 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 01:01:03
合計ジャッジ時間 2,641 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
23,568 KB
testcase_01 AC 22 ms
23,880 KB
testcase_02 AC 20 ms
24,372 KB
testcase_03 AC 29 ms
27,240 KB
testcase_04 AC 21 ms
23,628 KB
testcase_05 AC 31 ms
27,044 KB
testcase_06 AC 30 ms
27,424 KB
testcase_07 AC 30 ms
26,904 KB
testcase_08 AC 21 ms
24,080 KB
testcase_09 AC 21 ms
23,460 KB
testcase_10 AC 60 ms
27,444 KB
testcase_11 AC 21 ms
23,520 KB
testcase_12 AC 42 ms
27,228 KB
testcase_13 AC 52 ms
27,200 KB
testcase_14 AC 50 ms
27,392 KB
testcase_15 AC 50 ms
27,812 KB
testcase_16 AC 21 ms
23,568 KB
testcase_17 AC 20 ms
24,000 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 = reverse . nmk' []
 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