結果

問題 No.82 市松模様
ユーザー YamaKasaYamaKasa
提出日時 2018-04-23 23:52:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 177 ms / 5,000 ms
コード長 851 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 73,920 KB
実行使用メモリ 56,712 KB
最終ジャッジ日時 2023-09-09 21:40:23
合計ジャッジ時間 5,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,728 KB
testcase_01 AC 123 ms
55,704 KB
testcase_02 AC 122 ms
55,612 KB
testcase_03 AC 125 ms
55,704 KB
testcase_04 AC 125 ms
55,568 KB
testcase_05 AC 123 ms
56,712 KB
testcase_06 AC 128 ms
55,636 KB
testcase_07 AC 152 ms
55,416 KB
testcase_08 AC 167 ms
55,896 KB
testcase_09 AC 177 ms
56,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int W = scan.nextInt();
		int H = scan.nextInt();
		String C = scan.next();
		scan.close();
		String temp = C;
		if(W % 2 == 0) {
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if(temp.equals("W")) {
						System.out.print(temp);
						temp = "B";
					}else {
						System.out.print(temp);
						temp = "W";
					}
				}
				System.out.println();
				if(temp.equals("W")) {
					temp = "B";
				}else {
					temp = "W";
				}
			}
		}else {
			for(int i = 0; i < H; i++) {
				for(int j = 0; j < W; j++) {
					if(temp.equals("W")) {
						System.out.print(temp);
						temp = "B";
					}else {
						System.out.print(temp);
						temp = "W";
					}
				}
				System.out.println();
			}
		}
	}
}
0