結果
問題 | No.82 市松模様 |
ユーザー |
![]() |
提出日時 | 2017-10-20 18:11:50 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 186 ms / 5,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 2,099 ms |
コンパイル使用メモリ | 76,924 KB |
実行使用メモリ | 41,620 KB |
最終ジャッジ日時 | 2024-11-21 10:49:11 |
合計ジャッジ時間 | 4,239 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
import java.util.Scanner; public class Main { 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[][] ans = new String[h][w]; for(int i = 0 ; i < h ; i++) { for(int j = 0 ; j < w ; j++) { if(c.equals("B")) { if(i % 2 == 0) { if(j % 2 == 0) { ans[i][j] = "B"; } else { ans[i][j] = "W"; } } else { if(j % 2 == 0) { ans[i][j] = "W"; } else { ans[i][j] = "B"; } } } else { if(i % 2 == 0) { if(j % 2 == 0) { ans[i][j] = "W"; } else { ans[i][j] = "B"; } } else { if(j % 2 == 0) { ans[i][j] = "B"; } else { ans[i][j] = "W"; } } } } } for(int i = 0 ; i < h ; i++) { for(int j = 0 ; j < w ; j++) { System.out.print(ans[i][j]); } System.out.println(); } } }