結果
| 問題 |
No.429 CupShuffle
|
| コンテスト | |
| ユーザー |
aimy
|
| 提出日時 | 2017-06-21 09:51:03 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 870 bytes |
| コンパイル時間 | 392 ms |
| コンパイル使用メモリ | 148,608 KB |
| 最終ジャッジ日時 | 2024-11-14 20:05:15 |
| 合計ジャッジ時間 | 1,497 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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 qualified Data.ByteString.Char8 as B import Data.List import Data.Maybe import Control.Monad readInt = fst . fromJust . B.readInt swap i j im = M.insert j (im!i) (M.insert i (im!j) im) main = do [n,k,x] <- map read . words <$> getLine ab1s <- map (map readInt . B.words) <$> replicateM (x-1) B.getLine getLine ab2s <- map (map readInt . B.words) <$> replicateM (k-x) B.getLine cs <- map read . words <$> getLine let start = M.fromDistinctAscList (zip [1..n] [1..n]) let goal = M.fromDistinctAscList (zip [1..n] cs) putStrLn $ unwords $ map show (shuffle start ab1s goal ab2s) shuffle start ab1s goal ab2s = map succ $ findIndices id (zipWith (/=) prev next) where prev = M.elems $ foldl (\acc [a,b] -> swap a b acc) start ab1s next = M.elems $ foldr (\[a,b] acc -> swap a b acc) goal ab2s
aimy