結果

問題 No.82 市松模様
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-02-11 19:21:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 798 bytes
コンパイル時間 3,134 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 57,748 KB
最終ジャッジ日時 2023-10-21 23:17:00
合計ジャッジ時間 4,800 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,476 KB
testcase_01 AC 129 ms
57,292 KB
testcase_02 AC 128 ms
57,464 KB
testcase_03 AC 124 ms
57,448 KB
testcase_04 AC 132 ms
57,064 KB
testcase_05 AC 132 ms
57,612 KB
testcase_06 AC 138 ms
57,592 KB
testcase_07 AC 143 ms
57,656 KB
testcase_08 AC 182 ms
57,748 KB
testcase_09 AC 198 ms
57,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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

        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(c.equals("B")) {
                    System.out.print("B");
                    c = "W";
                } else {
                    System.out.print("W");
                    c = "B";
                }
            }
            System.out.println();
            if((w % 2) == 0) {
                if(c.equals("B")) {
                    c = "W";
                } else {
                    c = "B";
                }
            }
        }
    }
}
0