結果
問題 | No.82 市松模様 |
ユーザー |
|
提出日時 | 2017-03-18 23:20:57 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 138 ms / 5,000 ms |
コード長 | 861 bytes |
コンパイル時間 | 3,358 ms |
コンパイル使用メモリ | 81,108 KB |
実行使用メモリ | 41,396 KB |
最終ジャッジ日時 | 2024-07-04 19:55:48 |
合計ジャッジ時間 | 5,605 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.util.Scanner;public class No82 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int w = sc.nextInt();int h = sc.nextInt();String c = sc.next();String[] bw = new String[2];bw[0] = c;if (c.equals("B")) {bw[1] = "W";} else {bw[1] = "B";}String baseline = "";for (int x = 0; x < w + 1; x++) {baseline += (x % 2 == 0) ? bw[0] : bw[1];}String line0 = baseline.substring(0, w);String Line1 = baseline.substring(1, w + 1);for (int y = 0; y < h; y++) {if (y % 2 == 0) {System.out.println(line0);} else {System.out.println(Line1);}}sc.close();}}