結果

問題 No.351 市松スライドパズル
ユーザー momen999momen999
提出日時 2017-04-28 14:52:50
言語 Haskell
(9.6.2)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 13,198 ms
コンパイル使用メモリ 163,436 KB
実行使用メモリ 401,504 KB
最終ジャッジ日時 2023-10-11 18:55:51
合計ジャッジ時間 23,737 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,772 ms
266,232 KB
testcase_01 WA -
testcase_02 AC 3 ms
6,912 KB
testcase_03 WA -
testcase_04 AC 3 ms
6,968 KB
testcase_05 AC 3 ms
7,020 KB
testcase_06 AC 3 ms
7,024 KB
testcase_07 AC 3 ms
7,024 KB
testcase_08 AC 3 ms
6,936 KB
testcase_09 AC 3 ms
7,168 KB
testcase_10 AC 3 ms
7,148 KB
testcase_11 AC 3 ms
7,492 KB
testcase_12 AC 3 ms
7,456 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad

rInt :: String -> Int
rInt = read

rcTuple [rc,x] = (rc, rInt x)

solve _ _ [] x y
    | ((x + y) `mod` 2) == 0    = "white"
    | otherwise                 = "black"
solve w h (rc:rcs) x y
    | updateX   = solve w h rcs x' y
    | updateY   = solve w h rcs x y'
    | otherwise = solve w h rcs x y
    where
        updateX = (fst rc) == "R" && (snd rc) == y
        updateY = (fst rc) == "C" && (snd rc) == x
        x'  | (x - 1) < 0   = w - 1
            | otherwise     = x - 1
        y'  | (y - 1) < 0   = h - 1
            | otherwise     = y - 1

main = do
    [h, w] <- map rInt . words <$> getLine
    n <- readLn
    rc <- map (rcTuple . words) <$> replicateM n getLine
    putStrLn $ solve w h rc 0 0
0