結果
問題 | No.82 市松模様 |
ユーザー |
|
提出日時 | 2017-10-29 20:04:50 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 1,164 bytes |
コンパイル時間 | 3,294 ms |
コンパイル使用メモリ | 76,040 KB |
実行使用メモリ | 38,348 KB |
最終ジャッジ日時 | 2024-11-22 05:33:19 |
合計ジャッジ時間 | 4,562 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;public class No82 {public static void main(String[] args) throws IOException{String[] str = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");int w = Integer.parseInt(str[0]);int h = Integer.parseInt(str[1]);String[][] ichimatsu = new String[h][w];ichimatsu[0][0] = str[2];if(ichimatsu[0][0].equals("B")){for(int i=1; i < h; i+=2) ichimatsu[i][0] = "W";for(int i=2; i < h; i+=2) ichimatsu[i][0] = "B";}else{for(int i=1; i < h; i+=2) ichimatsu[i][0] = "B";for(int i=2; i < h; i+=2) ichimatsu[i][0] = "W";}makeIchimatsu(h,w,ichimatsu);for(int i=0; i < h; i++){for(int j=0; j < w; j++) System.out.print(ichimatsu[i][j]);System.out.println("");}}public static void makeIchimatsu(int h, int w, String[][] s){for(int i=0; i < h; i++){if(s[i][0].equals("B")){for(int j=1; j < w; j+=2) s[i][j] = "W";for(int j=2; j < w; j+=2) s[i][j] = "B";}else{for(int j=1; j < w; j+=2) s[i][j] = "B";for(int j=2; j < w; j+=2) s[i][j] = "W";}}}}