結果

問題 No.82 市松模様
ユーザー l1267976l1267976
提出日時 2017-03-18 23:20:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 861 bytes
コンパイル時間 4,170 ms
コンパイル使用メモリ 74,228 KB
実行使用メモリ 56,084 KB
最終ジャッジ日時 2023-09-18 03:21:45
合計ジャッジ時間 5,338 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,808 KB
testcase_01 AC 125 ms
55,828 KB
testcase_02 AC 123 ms
55,892 KB
testcase_03 AC 123 ms
55,948 KB
testcase_04 AC 128 ms
55,576 KB
testcase_05 AC 124 ms
55,956 KB
testcase_06 AC 125 ms
55,964 KB
testcase_07 AC 128 ms
56,084 KB
testcase_08 AC 132 ms
56,040 KB
testcase_09 AC 130 ms
55,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No82 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        String c = sc.next();

        String[] bw = new String[2];
        bw[0] = c;
        if (c.equals("B")) {
            bw[1] = "W";
        } else {
            bw[1] = "B";
        }

        String baseline = "";
        for (int x = 0; x < w + 1; x++) {
            baseline += (x % 2 == 0) ? bw[0] : bw[1];
        }

        String line0 = baseline.substring(0, w);
        String Line1 = baseline.substring(1, w + 1);

        for (int y = 0; y < h; y++) {
            if (y % 2 == 0) {
                System.out.println(line0);
            } else {
                System.out.println(Line1);
            }
        }

        sc.close();
    }

}
0