結果

問題 No.351 市松スライドパズル
コンテスト
ユーザー momen999
提出日時 2017-04-26 15:02:36
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 628 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,909 ms
コンパイル使用メモリ 196,480 KB
実行使用メモリ 389,888 KB
最終ジャッジ日時 2026-04-04 05:14:04
合計ジャッジ時間 28,098 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

-- 解説を参照
import Control.Monad

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 = solve w h rcs r' c'
    where
        r'  | (fst rc) == "C" && (snd rc) == c  = (r + h - 1) `mod` h
            | otherwise = r
        c'  | (fst rc) == "R" && (snd rc) == r  = (c + w - 1) `mod` w
            | otherwise = c

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