結果

問題 No.82 市松模様
ユーザー momen999momen999
提出日時 2019-04-04 11:54:37
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 480 bytes
コンパイル時間 3,089 ms
コンパイル使用メモリ 161,736 KB
実行使用メモリ 7,276 KB
最終ジャッジ日時 2023-08-26 18:17:13
合計ジャッジ時間 3,237 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,028 KB
testcase_01 AC 2 ms
7,068 KB
testcase_02 AC 2 ms
7,120 KB
testcase_03 AC 2 ms
7,000 KB
testcase_04 AC 2 ms
7,160 KB
testcase_05 AC 2 ms
7,256 KB
testcase_06 AC 3 ms
7,224 KB
testcase_07 AC 3 ms
7,244 KB
testcase_08 AC 2 ms
7,260 KB
testcase_09 AC 2 ms
7,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

main = getLine >>= mapM putStrLn . solve . (\[w, h, c] -> (map read [w, h], c)) . words

solve :: ([Int], String) -> [String]
solve ([w, h], c) = reverse $ f h where
    d = if c == "B" then "W" else "B"
    w2 = div w 2
    cd = concat $ zipWith (++) (replicate w2 c) (replicate w2 d)
    dc = reverse cd
    oddL = if odd w then cd ++ c else cd
    evenL = if odd w then dc ++ d else dc
    f 0 = []
    f i | odd i     = oddL : f (i - 1)
        | otherwise = evenL : f (i - 1)
0