結果

問題 No.82 市松模様
コンテスト
ユーザー YamaKasa
提出日時 2018-04-23 23:52:45
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 851 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,910 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 43,076 KB
最終ジャッジ日時 2026-03-15 12:55:56
合計ジャッジ時間 3,224 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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