結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-02 23:29:42 |
| 言語 | Haskell (9.10.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,123 bytes |
| コンパイル時間 | 8,266 ms |
| コンパイル使用メモリ | 181,000 KB |
| 実行使用メモリ | 19,612 KB |
| 最終ジャッジ日時 | 2024-06-30 09:10:21 |
| 合計ジャッジ時間 | 7,525 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 5 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.List (foldl', intercalate)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.Char (isSpace)
main :: IO ()
main = do
[n, k, x] <- f
solve n <$> replicateM (x-1) f <*> (getLine >> replicateM (k-x) f) <*> f >>= putStrLn
where f = readil B.readInt <$> B.getLine
solve :: Int -> [[Int]] -> [[Int]] -> [Int] -> String
solve n hs ts cs = intercalate " " . map show . foldr g [] $ zip3 [1..n] nhs nts
where swp ls ss = foldl' f ls ss
where f ls [i, j] = let (us, (v:vs)) = splitAt (i-1) ls
(vs', (w:ws)) = splitAt (j-i-1) vs
in us ++ (w:vs') ++ (v:ws)
nhs = swp [1..n] hs
nts = swp cs (reverse ts)
g (i, x, y) ls | x == y = ls
| otherwise = i:ls
readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')