結果

問題 No.351 市松スライドパズル
ユーザー aimyaimy
提出日時 2017-04-18 10:55:26
言語 Haskell
(9.8.2)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 704 bytes
コンパイル時間 5,099 ms
コンパイル使用メモリ 180,900 KB
実行使用メモリ 96,764 KB
最終ジャッジ日時 2024-04-27 02:25:26
合計ジャッジ時間 8,549 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
93,640 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 2 ms
6,816 KB
testcase_04 AC 2 ms
6,816 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 282 ms
94,672 KB
testcase_14 AC 323 ms
95,364 KB
testcase_15 AC 299 ms
96,632 KB
testcase_16 AC 298 ms
96,632 KB
testcase_17 AC 286 ms
96,644 KB
testcase_18 AC 270 ms
96,636 KB
testcase_19 AC 291 ms
96,640 KB
testcase_20 AC 288 ms
96,764 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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')
0