結果
| 問題 |
No.82 市松模様
|
| コンテスト | |
| ユーザー |
dsplit
|
| 提出日時 | 2019-08-14 17:19:14 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 764 bytes |
| コンパイル時間 | 1,984 ms |
| コンパイル使用メモリ | 171,392 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 14:31:56 |
| 合計ジャッジ時間 | 2,534 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.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
ソースコード
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]
dsplit