結果
問題 |
No.82 市松模様
|
ユーザー |
![]() |
提出日時 | 2016-01-17 01:16:22 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 127 ms / 5,000 ms |
コード長 | 1,152 bytes |
コンパイル時間 | 3,430 ms |
コンパイル使用メモリ | 80,560 KB |
実行使用メモリ | 54,244 KB |
最終ジャッジ日時 | 2024-09-19 20:16:53 |
合計ジャッジ時間 | 5,273 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
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(); } }