結果

問題 No.82 市松模様
ユーザー abcabc
提出日時 2016-11-02 12:47:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 724 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 72,260 KB
実行使用メモリ 56,412 KB
最終ジャッジ日時 2023-08-16 12:35:54
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,004 KB
testcase_01 AC 121 ms
55,844 KB
testcase_02 AC 120 ms
55,492 KB
testcase_03 AC 121 ms
55,912 KB
testcase_04 AC 126 ms
55,684 KB
testcase_05 AC 124 ms
55,828 KB
testcase_06 AC 129 ms
55,616 KB
testcase_07 AC 145 ms
55,832 KB
testcase_08 AC 177 ms
56,012 KB
testcase_09 AC 175 ms
56,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int WIDTH = sc.nextInt();
        int HEIGHT = sc.nextInt();
        char FIRST_LETTER = sc.next().charAt(0);

        char[] pattern = new char[2];

        if (FIRST_LETTER == 'B') {
            pattern[0] = 'B';
            pattern[1] = 'W';
        } else if (FIRST_LETTER == 'W') {
            pattern[0] = 'W';
            pattern[1] = 'B';
        }

        for (int i = 0; i < HEIGHT; i++) {

            for (int j = 0; j < WIDTH; j++) {

                System.out.print(pattern[(i + j) % 2]);

            }

            System.out.println();

        }

    }

}
0