結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,460 KB
testcase_01 AC 137 ms
57,420 KB
testcase_02 AC 135 ms
57,452 KB
testcase_03 AC 136 ms
57,496 KB
testcase_04 AC 140 ms
57,704 KB
testcase_05 AC 138 ms
57,456 KB
testcase_06 AC 142 ms
57,656 KB
testcase_07 AC 158 ms
57,700 KB
testcase_08 AC 198 ms
57,736 KB
testcase_09 AC 195 ms
57,740 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