結果

問題 No.351 市松スライドパズル
ユーザー ducktailducktail
提出日時 2018-08-14 13:56:33
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 7,403 ms
コンパイル使用メモリ 166,296 KB
実行使用メモリ 413,648 KB
最終ジャッジ日時 2023-10-24 17:03:38
合計ジャッジ時間 32,557 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,662 ms
220,084 KB
testcase_01 AC 2 ms
5,232 KB
testcase_02 AC 2 ms
5,232 KB
testcase_03 AC 2 ms
5,264 KB
testcase_04 AC 2 ms
5,244 KB
testcase_05 AC 2 ms
5,264 KB
testcase_06 AC 2 ms
5,268 KB
testcase_07 AC 2 ms
5,276 KB
testcase_08 AC 2 ms
5,220 KB
testcase_09 AC 2 ms
5,312 KB
testcase_10 AC 2 ms
5,312 KB
testcase_11 AC 2 ms
5,672 KB
testcase_12 AC 2 ms
5,672 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.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.List (foldl')

main :: IO ()
main = do
  [h, w] <- map read <$> words <$> getLine
  n <- readLn
  solve h w <$> getops n >>= putStrLn

solve :: Int -> Int -> [(Char, Int)] -> String
solve h w ops = g $ foldl' f (0,0) ops
  where f (r, c) (s, k) | s == 'R' && r == k = (r, (c-1) `mod` w)
                        | s == 'C' && c == k = ((r-1) `mod` h, c)
                        | otherwise = (r, c)
        g (r, c) | even (r+c) = "white"
                 | otherwise = "black"

getops :: Int -> IO [(Char, Int)]
getops n = f n []
  where f x acs | x == 0 = return acs
                | otherwise = do
                    [a, b] <- words <$> getLine
                    f (x-1) ((head a, read b):acs)
0