結果

問題 No.490 yukiソート
コンテスト
ユーザー Leonardone
提出日時 2017-03-13 00:41:19
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 536 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,139 ms
コンパイル使用メモリ 192,896 KB
実行使用メモリ 50,816 KB
最終ジャッジ日時 2026-03-19 16:48:33
合計ジャッジ時間 34,792 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

-- yukicoder My practice
-- author: Leonardone @ NEETSDKASU

import Data.List (foldl')

main = getContents >>= putStrLn . unwords . map show . solve . map read . words

solve (n:xs) = baz n xs

baz n xs = foldl' (bar n) xs [1 .. 2 * n - 4]

bar n xs i = foldl' (\xs k -> foo k (i - k) xs) xs
           $ [k | k <- [0 .. i], k < i - k, k < n, i - k < n]
        
foo p q as = bs where
    (xs2, (aq:xs1)) = splitAt q as
    (xs4, (ap:xs3)) = splitAt p xs2
    bp = min ap aq
    bq = max ap aq
    bs = xs4 ++ [bp] ++ xs3 ++ [bq] ++ xs1
0