結果
問題 | No.82 市松模様 |
ユーザー |
![]() |
提出日時 | 2016-05-22 15:20:39 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 159 ms / 5,000 ms |
コード長 | 769 bytes |
コンパイル時間 | 3,180 ms |
コンパイル使用メモリ | 77,268 KB |
実行使用メモリ | 41,160 KB |
最終ジャッジ日時 | 2024-10-06 20:31:35 |
合計ジャッジ時間 | 3,691 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.util.*;class No0082{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 tmp = "";String[][] str = new String[h][w];for(int i = 0; i < h; i++){if(i == 0){str[0][0] = c;tmp = c;}else if(str[i - 1][0].equals("B")){str[i][0] = "W";tmp = "W";}else if(str[i - 1][0].equals("W")){str[i][0] = "B";tmp = "B";}for(int j = 1; j < w; j++){if(tmp.equals("B")){str[i][j] = "W";tmp = "W";}else{str[i][j] = "B";tmp = "B";}}}for(int i = 0; i < h; i++){for(int j = 0; j < w; j++){System.out.print(str[i][j]);}System.out.println();}}}