結果
| 問題 |
No.351 市松スライドパズル
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-28 14:52:50 |
| 言語 | Haskell (9.10.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 736 bytes |
| コンパイル時間 | 5,647 ms |
| コンパイル使用メモリ | 176,768 KB |
| 実行使用メモリ | 391,040 KB |
| 最終ジャッジ日時 | 2024-09-13 17:49:55 |
| 合計ジャッジ時間 | 21,207 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 9 TLE * 8 |
コンパイルメッセージ
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
ソースコード
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