結果

問題 No.82 市松模様
ユーザー kaoetayakaoetaya
提出日時 2016-11-10 15:24:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 174 ms / 5,000 ms
コード長 780 bytes
コンパイル時間 3,506 ms
コンパイル使用メモリ 74,336 KB
実行使用メモリ 56,344 KB
最終ジャッジ日時 2023-08-16 17:33:31
合計ジャッジ時間 5,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
56,020 KB
testcase_01 AC 125 ms
55,600 KB
testcase_02 AC 124 ms
55,744 KB
testcase_03 AC 125 ms
55,808 KB
testcase_04 AC 133 ms
55,756 KB
testcase_05 AC 128 ms
56,112 KB
testcase_06 AC 132 ms
55,672 KB
testcase_07 AC 158 ms
56,344 KB
testcase_08 AC 172 ms
56,284 KB
testcase_09 AC 174 ms
56,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class pre {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
		int w = s.nextInt(),h = s.nextInt();
		String c = s.next();
		
		String[] str = new String[w*h];
		
		for(int i=0;i<w*h;i++){
			if(i >= w && i%w == 0 && str[i-1].equals("B") && w%2 == 0){
				str[i] = "B";
			}
			else if(i >= w && i%w == 0 && str[i-1].equals("W") && w%2 == 0){
				str[i] = "W";
			}
			else if(c.equals("B")){
				str[i] = c;
				c = "W";
			}
			else if(c.equals("W")){
				str[i] = c;
				c = "B";
			}
		}
		
		int cnt=0;
		
		for(int i=0;i<w*h;i++){
			if(cnt == w){
				System.out.println();
				cnt = 0;
				System.out.print(str[i]);
				cnt++;
			}
			else{
				System.out.print(str[i]);
				cnt++;
			}
		}
    }
}
0