結果
問題 | No.490 yukiソート |
ユーザー | atuk721 |
提出日時 | 2017-05-06 05:02:41 |
言語 | Haskell (9.8.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 927 bytes |
コンパイル時間 | 7,142 ms |
コンパイル使用メモリ | 161,040 KB |
実行使用メモリ | 19,912 KB |
最終ジャッジ日時 | 2023-10-12 14:05:39 |
合計ジャッジ時間 | 10,557 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,264 KB |
testcase_01 | AC | 3 ms
7,212 KB |
testcase_02 | AC | 3 ms
7,612 KB |
testcase_03 | AC | 3 ms
7,488 KB |
testcase_04 | AC | 142 ms
19,720 KB |
testcase_05 | AC | 142 ms
19,752 KB |
testcase_06 | AC | 143 ms
19,728 KB |
testcase_07 | AC | 142 ms
19,720 KB |
testcase_08 | AC | 143 ms
19,692 KB |
testcase_09 | AC | 142 ms
19,712 KB |
testcase_10 | AC | 142 ms
19,648 KB |
testcase_11 | AC | 152 ms
19,912 KB |
testcase_12 | AC | 142 ms
19,764 KB |
testcase_13 | AC | 143 ms
19,756 KB |
testcase_14 | TLE | - |
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 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
コンパイルメッセージ
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
ソースコード
import qualified Data.IntMap.Lazy as M main :: IO () main = do n <- readLn is <- map read . words <$> getLine let m = createMap n result = yukisort n 1 m is putStrLn . unwords . map show $ result yukisort :: Int -> Int -> M.IntMap [(Int, Int)] -> [Int] -> [Int] yukisort n i map xs | i >= 2 * n - 3 = xs | otherwise = yukisort n (i + 1) map $ foldl (\a v -> proc v a) xs ((M.!) map i) where proc (p, q) ys | ys !! p > ys !! q = swap p q ys | otherwise = ys createMap :: Int -> M.IntMap [(Int, Int)] createMap n = foldl (\m (p, q) -> M.insertWith insertFunc (p + q) [(p, q)] m) M.empty comb where comb = [(p, q) | p <- [0..n - 1], q <- [0..n - 1], p < q] insertFunc n o = (n !! 0) : o swap :: Int -> Int -> [Int] -> [Int] swap i j as@(x:xs) | i == 0 || j == 0 = let m = max i j in as !! m : take (m - 1) xs ++ x : drop m xs | otherwise = x : swap (i - 1) (j - 1) xs