結果

問題 No.82 市松模様
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-26 22:32:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 1,288 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 49,540 KB
最終ジャッジ日時 2023-10-11 14:07:35
合計ジャッジ時間 3,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,272 KB
testcase_01 AC 43 ms
49,540 KB
testcase_02 AC 43 ms
49,176 KB
testcase_03 AC 43 ms
49,080 KB
testcase_04 AC 45 ms
49,452 KB
testcase_05 AC 43 ms
49,372 KB
testcase_06 AC 44 ms
49,468 KB
testcase_07 AC 45 ms
49,176 KB
testcase_08 AC 50 ms
49,480 KB
testcase_09 AC 49 ms
49,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = reader.readLine().split(" ");
        int W = Integer.parseInt(inputs[0]);
        int H = Integer.parseInt(inputs[1]);
        String C = inputs[2];


        for (int i = 0; i < H; i++) {
            String leftMostPattern;
            if (i % 2 == 0) {
                leftMostPattern = C;
            } else {
                leftMostPattern = nextPattern(C);
            }
            StringBuilder builder = new StringBuilder(leftMostPattern);
            for (int j = 1; j < W; j++) {
                leftMostPattern = nextPattern(leftMostPattern);
                builder.append(leftMostPattern);
            }
            System.out.println(builder.toString());
        }
    }

    private static String nextPattern(String currentPattern) {
        if (currentPattern.equals("B")) {
            return "W";
        } else {
            return "B";
        }
    }


}
0