結果

問題 No.82 市松模様
ユーザー k_kadorak_kadora
提出日時 2015-05-23 23:40:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 715 bytes
コンパイル時間 3,484 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 58,052 KB
最終ジャッジ日時 2023-09-20 10:55:49
合計ジャッジ時間 5,331 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,032 KB
testcase_01 AC 127 ms
56,028 KB
testcase_02 AC 125 ms
56,348 KB
testcase_03 AC 128 ms
56,004 KB
testcase_04 AC 126 ms
55,724 KB
testcase_05 AC 124 ms
55,940 KB
testcase_06 AC 129 ms
55,868 KB
testcase_07 AC 153 ms
55,860 KB
testcase_08 AC 177 ms
58,052 KB
testcase_09 AC 178 ms
57,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Ichimatsu{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int w,h;
		char b;
		w = sc.nextInt();
		h = sc.nextInt();
		b = sc.next().charAt(0);
		if(b == 'B'){
			for(int i = 0;i<h;i++){
				for(int j = 0;j<w;j++){
					if(((j%2 == 0) && (i%2 == 0))||((j%2 == 1)&&(i%2 == 1))){
						System.out.print("B");
					}else{
						System.out.print("W");
					}
				}
				System.out.println("");
			}
		}else{
			for(int i = 0;i<h;i++){
				for(int j = 0;j<w;j++){
					if(((j%2 == 0) && (i%2 == 0))||((j%2 == 1)&&(i%2 == 1))){
						System.out.print("W");
					}else{
						System.out.print("B");
					}
				}
				System.out.println("");
			}
		}
	}
}
		
0