結果

問題 No.351 市松スライドパズル
ユーザー momen999momen999
提出日時 2017-04-26 23:49:33
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 1,133 bytes
コンパイル時間 4,454 ms
コンパイル使用メモリ 161,812 KB
実行使用メモリ 483,792 KB
最終ジャッジ日時 2023-10-11 14:14:25
合計ジャッジ時間 14,571 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
import Debug.Trace

rInt :: String -> Int
rInt = read

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

solve _ _ [] r c
    | ((r + c) `mod` 2) == 0    = "white"
    | otherwise                 = "black"
solve w h (rc:rcs) r c
    | updateR || updateC    = solve w h rcs r' c'
    | otherwise             = solve w c rcs r c
    where
        updateR = (fst rc) == "C" && (snd rc) == c
        updateC = (fst rc) == "R" && (snd rc) == r
        r'  | updateR   = (r + h - 1) `mod` h
            | otherwise = r
        c'  | updateC   = (c + w - 1) `mod` w
            | otherwise = c
        --r'  | updateR   = trace ("R : " ++ show r ++ "->" ++ show ((r + h - 1) `mod` h)) ((r + h - 1) `mod` h)
        --    | otherwise = trace ("R : " ++ show r) r
        --c'  | updateC   = trace ("C : " ++ show c ++ "->" ++ show ((c + w - 1) `mod` w)) ((c + w - 1) `mod` w)
        --    | otherwise = trace ("C : " ++ show c) c

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