結果
問題 | No.82 市松模様 |
ユーザー | ohagi_1182 |
提出日時 | 2017-10-20 18:11:50 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 167 ms / 5,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 1,893 ms |
コンパイル使用メモリ | 77,508 KB |
実行使用メモリ | 42,108 KB |
最終ジャッジ日時 | 2024-05-01 07:57:32 |
合計ジャッジ時間 | 3,671 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
41,724 KB |
testcase_01 | AC | 101 ms
41,328 KB |
testcase_02 | AC | 110 ms
41,876 KB |
testcase_03 | AC | 111 ms
41,240 KB |
testcase_04 | AC | 108 ms
41,308 KB |
testcase_05 | AC | 122 ms
41,632 KB |
testcase_06 | AC | 111 ms
41,708 KB |
testcase_07 | AC | 129 ms
41,452 KB |
testcase_08 | AC | 167 ms
42,068 KB |
testcase_09 | AC | 148 ms
42,108 KB |
ソースコード
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(); } } }