結果
問題 | No.351 市松スライドパズル |
ユーザー | ducktail |
提出日時 | 2018-08-14 14:00:42 |
言語 | Haskell (9.8.2) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 971 bytes |
コンパイル時間 | 3,379 ms |
コンパイル使用メモリ | 141,988 KB |
最終ジャッジ日時 | 2023-10-24 17:05:49 |
合計ジャッジ時間 | 4,471 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:3:1: error: Could not load module ‘Data.ByteString.Char8’ It is a member of the hidden package ‘bytestring-0.11.4.0’. You can run ‘:set -package bytestring’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 3 | import Data.ByteString.Char8 (ByteString) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Main.hs:4:1: error: Could not load module ‘Data.ByteString.Char8’ It is a member of the hidden package ‘bytestring-0.11.4.0’. You can run ‘:set -package bytestring’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 4 | import qualified Data.ByteString.Char8 as B | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative ((<$>)) import Data.List (foldl') import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B main :: IO () main = do [h, w] <- map read <$> words <$> getLine n <- readLn solve h w <$> getops n >>= putStrLn solve :: Int -> Int -> [(Char, Int)] -> String solve h w ops = g $ foldl' f (0,0) ops where f (r, c) (s, k) | s == 'R' && r == k = (r, (c-1) `mod` w) | s == 'C' && c == k = ((r-1) `mod` h, c) | otherwise = (r, c) g (r, c) | even (r+c) = "white" | otherwise = "black" getops :: Int -> IO [(Char, Int)] getops n = f n [] where f x acs | x == 0 = return acs | otherwise = do [a, b] <- B.words <$> B.getLine f (x-1) ((B.head a, readi B.readInt b):acs) readi :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> a readi f s = let Just (n, _) = f s in n