結果

問題 No.82 市松模様
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-12 06:49:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 908 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 74,132 KB
実行使用メモリ 56,124 KB
最終ジャッジ日時 2023-08-17 02:05:38
合計ジャッジ時間 5,064 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,584 KB
testcase_01 AC 127 ms
55,772 KB
testcase_02 AC 127 ms
55,772 KB
testcase_03 AC 124 ms
55,960 KB
testcase_04 AC 131 ms
55,644 KB
testcase_05 AC 129 ms
55,872 KB
testcase_06 AC 134 ms
55,688 KB
testcase_07 AC 154 ms
54,052 KB
testcase_08 AC 176 ms
56,124 KB
testcase_09 AC 177 ms
55,688 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        String C = sc.next();
        String [][]map = new String [H][W];
        map[0][0]=C;
        for(int i=0; i<H; i++){
            if(i!=0){
                if( "B".equals(map[i-1][0]) ){
                    map[i][0]="W";
                }else{
                    map[i][0]="B";
                }
            }
            for(int j=1; j<W; j++){
                if( "B".equals(map[i][j-1]) ){
                    map[i][j]="W";
                }else{
                    map[i][j]="B";
                }
            }
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                System.out.print(map[i][j]);
            }
            System.out.println();
        }
    }
}
0