結果
| 問題 | No.366 ロボットソート | 
| コンテスト | |
| ユーザー |  aimy | 
| 提出日時 | 2017-06-21 16:43:23 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                CE
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 789 bytes | 
| コンパイル時間 | 183 ms | 
| コンパイル使用メモリ | 149,248 KB | 
| 最終ジャッジ日時 | 2024-11-14 20:05:14 | 
| 合計ジャッジ時間 | 582 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
            
            
            
            
            ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
Main.hs:1:1: error: [GHC-87110]
    Could not load module ‘Data.IntMap’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
1 | import Data.IntMap ((!))
  | ^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:2:1: error: [GHC-87110]
    Could not load module ‘Data.IntMap’.
    It is a member of the hidden package ‘containers-0.6.8’.
    Use -v to see a list of the files searched for.
  |
2 | import qualified Data.IntMap as M
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            
            ソースコード
import Data.IntMap ((!)) import qualified Data.IntMap as M import Control.Monad import Data.List apply n f x = foldr ($) x (replicate n f) splitOn n = unfoldr (\xs -> guard ((not.null) xs) >> return (splitAt n xs)) nBubble xs = fst $ apply (length xs - 1) replace (0,ixs) where replace (n,im) = foldr (\i acc -> swap i (i+1) acc) (n,im) [1 .. length xs - 1] ixs = M.fromList (zip [1..] xs) swap i j (n,im) | im!i > im!j = (n+1, M.insert i (im!j) (M.insert j (im!i) im)) | otherwise = (n,im) main = do [_,k] <- map read . words <$> getLine as <- map read . words <$> getLine :: IO [Int] putStrLn $ maybe "-1" show (rsort k as) rsort k as = do let ms = transpose $ splitOn k as let sms = map sort ms guard (concat (transpose sms) == sort as) return $ sum (map nBubble ms)
