結果
問題 | No.82 市松模様 |
ユーザー | r.suzuki |
提出日時 | 2016-01-17 01:16:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 140 ms / 5,000 ms |
コード長 | 1,152 bytes |
コンパイル時間 | 3,901 ms |
コンパイル使用メモリ | 81,612 KB |
実行使用メモリ | 57,804 KB |
最終ジャッジ日時 | 2023-10-20 00:24:23 |
合計ジャッジ時間 | 6,040 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
57,648 KB |
testcase_01 | AC | 137 ms
57,640 KB |
testcase_02 | AC | 134 ms
57,716 KB |
testcase_03 | AC | 132 ms
57,564 KB |
testcase_04 | AC | 135 ms
57,804 KB |
testcase_05 | AC | 132 ms
57,716 KB |
testcase_06 | AC | 132 ms
57,396 KB |
testcase_07 | AC | 135 ms
57,104 KB |
testcase_08 | AC | 135 ms
57,316 KB |
testcase_09 | AC | 140 ms
57,184 KB |
ソースコード
enum Color{ BLACK,WHITE; } class Paper{ final int width; final int height; final Color color; String line1 = ""; String line2 = ""; public Paper(int i,int j,String s){ this.width = i; this.height = j; if(s.equals("B")){ this.color = Color.BLACK; } else{ this.color = Color.WHITE; } } public void show(){ makeLine(); reverse(); for(int i = 0;i < height;i++){ if(i%2 == 0){ System.out.println(line1); } else{ System.out.println(line2); } } } public void makeLine(){ String s1,s2; if(this.color.equals(Color.BLACK)){ s1 = "B"; s2 = "W"; } else{ s1 = "W"; s2 = "B"; } for(int i = 0;i < this.width;i++){ if(i%2 == 0){ line1 += s1; } else{ line1 += s2; } } } public void reverse(){ String tmp = line1; tmp = tmp.replaceAll("B","t"); tmp = tmp.replaceAll("W","B"); tmp = tmp.replaceAll("t","W"); line2 += tmp; } } public class No_82{ public static void main(String[] args){ java.util.Scanner sc = new java.util.Scanner(System.in); Paper paper = new Paper(sc.nextInt(),sc.nextInt(),sc.next()); paper.show(); } }