結果

問題 No.82 市松模様
ユーザー dsplitdsplit
提出日時 2019-08-14 17:19:14
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 164,108 KB
実行使用メモリ 5,236 KB
最終ジャッジ日時 2023-10-19 18:11:25
合計ジャッジ時間 2,710 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,188 KB
testcase_01 AC 2 ms
5,188 KB
testcase_02 AC 2 ms
5,188 KB
testcase_03 AC 2 ms
5,188 KB
testcase_04 AC 3 ms
5,228 KB
testcase_05 AC 2 ms
5,192 KB
testcase_06 AC 2 ms
5,196 KB
testcase_07 AC 3 ms
5,216 KB
testcase_08 AC 2 ms
5,236 KB
testcase_09 AC 2 ms
5,236 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:22:13: warning: [GHC-94817] [-Wtabs]
    Tab character found here, and in 7 further locations.
    Suggested fix: Please use spaces instead.
   |
22 |                         then putStrLn $ intersperse (f c) $ replicate ((w + 1) `div` 2) (g c)
   |             ^^^^
[2 of 2] Linking a.out

ソースコード

diff #

import Data.List
import Control.Monad

f :: String -> Char
f "W" = 'B'
f "B" = 'W'
f  _  = '@'

g :: String -> Char
g "W" = 'W'
g "B" = 'B'
g  _  = '@'

main :: IO ()
main = do
    [a, b, c] <- words <$> getLine
    let w = (read :: String -> Int) a
        h = (read :: String -> Int) b
    forM_ [1..h] $ \i -> do
        if i `mod` 2 == 1
            then if w `mod` 2 == 1 
            		then putStrLn $ intersperse (f c) $ replicate ((w + 1) `div` 2) (g c)
            		else putStrLn $ (intersperse (f c) $ replicate (w `div` 2) (g c)) ++ [f c]
            else if w `mod` 2 == 1
            		then putStrLn $ intersperse (g c) $ replicate ((w + 1) `div` 2) (f c)
            		else putStrLn $ (intersperse (g c) $ replicate ((w + 1) `div` 2) (f c)) ++ [g c]
0