結果

問題 No.82 市松模様
ユーザー chiho_miyako
提出日時 2015-04-09 10:35:54
言語 Java
(openjdk 23)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 974 bytes
コンパイル時間 2,338 ms
コンパイル使用メモリ 77,848 KB
実行使用メモリ 41,400 KB
最終ジャッジ日時 2024-07-04 13:22:27
合計ジャッジ時間 4,353 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int w = koko.nextInt();
        int h = koko.nextInt();
        String c = koko.next();
        char[][] iro = new char[h][w];
        if(c.equals("B")){
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if((i+j)%2==0){
                        iro[i][j]='B';
                    }else{
                        iro[i][j]='W';
                    }
                }
                System.out.println(iro[i]);
            }
        }else{
            for(int i=0; i<h; i++){
                for(int j=0; j<w; j++){
                    if((i+j)%2==0){
                        iro[i][j]='W';
                    }else{
                        iro[i][j]='B';
                    }
                }
                System.out.println(iro[i]);
            }
        }
    }
}
0