結果

問題 No.82 市松模様
ユーザー ちよちゃんちよちゃん
提出日時 2016-06-04 14:50:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 938 bytes
コンパイル時間 3,500 ms
コンパイル使用メモリ 77,560 KB
実行使用メモリ 54,428 KB
最終ジャッジ日時 2024-04-17 00:18:30
合計ジャッジ時間 5,635 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,092 KB
testcase_01 AC 132 ms
54,076 KB
testcase_02 AC 132 ms
54,364 KB
testcase_03 AC 130 ms
54,204 KB
testcase_04 AC 137 ms
54,396 KB
testcase_05 AC 134 ms
54,260 KB
testcase_06 AC 141 ms
54,240 KB
testcase_07 AC 155 ms
54,416 KB
testcase_08 AC 180 ms
54,308 KB
testcase_09 AC 190 ms
54,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Scanner;

public class Yuki82 {
	
	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();
		
		for (int j = 1; j <= h; j++) {
			for (int i = 1; i <= w; i++) {
				test(c,j,i);
			}
			System.out.print("\n");
		}
	}
	
	private static void test(String str,int j,int i) {
		
		if("B".equals(str)){
			if(j%2 == 0) {
				if (i%2 == 0){
					System.out.print("B");
				} else { 
					System.out.print("W");
				}
			}else {
				if (i%2 != 0){
					System.out.print("B");
				} else { 
					System.out.print("W");
				}			
			}
		} else {
			if(j%2 == 0) {
				if (i%2 == 0){
					System.out.print("W");
				} else { 
					System.out.print("B");
				}
			}else {
				if (i%2 != 0){
					System.out.print("W");
				} else { 
					System.out.print("B");
				}			
			}			
		}
	}
}
0