結果

問題 No.82 市松模様
ユーザー spacenautspacenaut
提出日時 2016-05-22 15:20:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 199 ms / 5,000 ms
コード長 769 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 77,060 KB
実行使用メモリ 41,920 KB
最終ジャッジ日時 2024-04-16 06:47:20
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
41,500 KB
testcase_01 AC 136 ms
41,556 KB
testcase_02 AC 134 ms
41,240 KB
testcase_03 AC 137 ms
41,340 KB
testcase_04 AC 140 ms
41,240 KB
testcase_05 AC 137 ms
41,296 KB
testcase_06 AC 144 ms
41,464 KB
testcase_07 AC 161 ms
41,440 KB
testcase_08 AC 196 ms
41,820 KB
testcase_09 AC 199 ms
41,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class No0082{
	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 tmp = "";
		String[][] str = new String[h][w];

		for(int i = 0; i < h; i++){
			if(i == 0){
				str[0][0] = c;
				tmp = c;
			}else if(str[i - 1][0].equals("B")){
				str[i][0] = "W";
				tmp = "W";
			}else if(str[i - 1][0].equals("W")){
				str[i][0] = "B";
				tmp = "B";
			}
			for(int j = 1; j < w; j++){
				if(tmp.equals("B")){
					str[i][j] = "W";
					tmp = "W";
				}else{
					str[i][j] = "B";
					tmp = "B";
				}
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				System.out.print(str[i][j]);
			}
			System.out.println();
		}
	}
}
0