結果

問題 No.82 市松模様
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-10-29 20:04:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 1,164 bytes
コンパイル時間 3,722 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 38,392 KB
最終ジャッジ日時 2024-05-01 22:21:08
合計ジャッジ時間 4,861 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
36,972 KB
testcase_01 AC 53 ms
36,528 KB
testcase_02 AC 53 ms
36,748 KB
testcase_03 AC 54 ms
36,564 KB
testcase_04 AC 56 ms
37,032 KB
testcase_05 AC 53 ms
37,096 KB
testcase_06 AC 55 ms
37,040 KB
testcase_07 AC 63 ms
36,904 KB
testcase_08 AC 105 ms
38,104 KB
testcase_09 AC 121 ms
38,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No82 {
	public static void main(String[] args) throws IOException{
		String[] str = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");
		int w = Integer.parseInt(str[0]);
		int h = Integer.parseInt(str[1]);
		String[][] ichimatsu = new String[h][w];
		ichimatsu[0][0] = str[2];
		if(ichimatsu[0][0].equals("B")){
			for(int i=1; i < h; i+=2) ichimatsu[i][0] = "W";
			for(int i=2; i < h; i+=2) ichimatsu[i][0] = "B";
		}
		else{
			for(int i=1; i < h; i+=2) ichimatsu[i][0] = "B";
			for(int i=2; i < h; i+=2) ichimatsu[i][0] = "W";
		}
		makeIchimatsu(h,w,ichimatsu);
		for(int i=0; i < h; i++){
			for(int j=0; j < w; j++) System.out.print(ichimatsu[i][j]);
			System.out.println("");
		}
	}
	
	public static void makeIchimatsu(int h, int w, String[][] s){
		for(int i=0; i < h; i++){
			if(s[i][0].equals("B")){
			    for(int j=1; j < w; j+=2)  s[i][j] = "W";
			    for(int j=2; j < w; j+=2)  s[i][j] = "B";
			}
			else{
				for(int j=1; j < w; j+=2)  s[i][j] = "B";
				for(int j=2; j < w; j+=2)  s[i][j] = "W";
			}
		}
	}
}
0