結果

問題 No.82 市松模様
ユーザー tenten
提出日時 2020-11-10 15:32:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 631 bytes
コンパイル時間 1,801 ms
コンパイル使用メモリ 73,944 KB
実行使用メモリ 41,416 KB
最終ジャッジ日時 2024-07-22 17:31:57
合計ジャッジ時間 3,478 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        char[] dis = new char[]{'B', 'W'};
        int add;
        if (sc.next().charAt(0) == 'B') {
            add = 0;
        } else {
            add = 1;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                sb.append(dis[(i + j + add) % 2]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}
0