結果
問題 | No.351 市松スライドパズル |
ユーザー | aimy |
提出日時 | 2017-04-18 10:55:26 |
言語 | Haskell (9.6.2) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 704 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 143,188 KB |
最終ジャッジ日時 | 2023-10-25 07:51:59 |
合計ジャッジ時間 | 1,185 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:1: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. | 1 | import qualified Data.ByteString.Char8 as B | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import qualified Data.ByteString.Char8 as B import Data.Maybe query :: Int -> Int -> String query h w | odd h == odd w = "white" | otherwise = "black" main = do [h,w] <- map read . words <$> getLine getLine sks <- map ((\[s,k]-> (B.unpack s, (fst . fromJust . B.readInt) k)) . B.words) . B.lines <$> B.getContents putStrLn $ (ichimatsu h w sks) ichimatsu :: Int -> Int -> [(String,Int)] -> String ichimatsu h w sks = uncurry query $ foldr (sim h w) (0,0) sks sim :: Int -> Int -> (String,Int) -> (Int,Int) -> (Int,Int) sim h w ("R",k) (h',w') | k/=h' = (h',w') | w'==0 = (h',w-1) | otherwise = (h',w'-1) sim h w ("C",k) (h',w') | k/=w' = (h',w') | h'==0 = (h-1,w') | otherwise = (h'-1,w')