結果

問題 No.82 市松模様
ユーザー h_tyokinuhatah_tyokinuhata
提出日時 2016-01-24 02:53:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 205 ms / 5,000 ms
コード長 689 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 77,372 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-10-21 13:52:43
合計ジャッジ時間 4,651 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
57,664 KB
testcase_01 AC 141 ms
57,608 KB
testcase_02 AC 136 ms
57,480 KB
testcase_03 AC 138 ms
57,460 KB
testcase_04 AC 143 ms
57,756 KB
testcase_05 AC 140 ms
57,148 KB
testcase_06 AC 147 ms
57,708 KB
testcase_07 AC 169 ms
57,656 KB
testcase_08 AC 199 ms
57,720 KB
testcase_09 AC 205 ms
57,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int W = sc.nextInt(), H = sc.nextInt();
		String C = sc.next();
		
		String[][] mark = new String[W][H];
		
		String C2;
		
		if(C.equals("B")) {
			C2 = "W";
		} else {
			C2= "B";
		}
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(i % 2 == 0 && j % 2 != 0) {
					mark[j][i] = C2;
				} else if(i % 2 != 0 && j % 2 == 0) {
					mark[j][i] = C2;
				} else {
					mark[j][i] = C;
				}
			}
		}
		
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				System.out.print(mark[j][i]);
			}
			
			System.out.println();
		}
	}
}
0