結果

問題 No.82 市松模様
ユーザー tanson
提出日時 2025-08-23 02:47:10
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 1,203 bytes
コンパイル時間 2,933 ms
コンパイル使用メモリ 689,148 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-08-23 02:47:14
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)

fun readChar () = valOf (TextIO.scanStream Char.scan TextIO.stdIn)



val () =
    let
        val w = readInt ()
        val h = readInt ()
        val _ = readChar ()     (* skip *)
        val c = readChar ()
                        
        fun printAns () =
            let
                fun makeLine 0 _ = []
                  | makeLine n ch = 
                    if ch = #"B" then #"B" :: makeLine (n - 1) #"W"
                    else #"W" :: makeLine (n - 1) #"B"
           
                fun makeLines 0 _ = ignore ()
                  | makeLines n ch =
                    if ch = #"B"
                    then
                        (
                          print (String.implode (makeLine w #"B") ^ "\n");
                          makeLines (n - 1) #"W"
                        )
                    else
                        (
                          print (String.implode (makeLine w #"W") ^ "\n");
                          makeLines (n - 1) #"B"
                        )          
            in    
                makeLines h c
            end
    in
        printAns ()
    end
0