結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2017-03-28 21:03:20 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 3,358 ms |
コンパイル使用メモリ | 77,900 KB |
実行使用メモリ | 55,060 KB |
最終ジャッジ日時 | 2024-10-03 03:36:45 |
合計ジャッジ時間 | 11,927 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 33 WA * 7 |
ソースコード
import java.util.Scanner; public class Nuriwake { public static void main(String[] args) { Scanner s = new Scanner(System.in); int H = s.nextInt(), W = s.nextInt(),count = 0;; int[][][] color = new int[H][W][2]; for(int i = 0;i < H;i++){ String str = s.next(); for(int j = 0;j < W;j++){ if(str.charAt(j) == '#'){ color[i][j][0] = 1; //1は[0]なら黒、[1]なら青候補 count++; } } } s.close(); if(count%2 == 1){ System.out.println("NO"); }else{ int redc = count / 2; for(int x = 0;x < W;x++){ for(int y = 0;y < H;y++){ int c = 0; for(int i = 0;i < H-y;i++){ for(int j = 0;j < W-x;j++){ if(color[i][j][0] == 1&&color[i+y][j+x][0] == 1&&color[i+y][j+x][1] == 0&&color[i][j][1] == 0){ color[i+y][j+x][1] = 1; c++; //System.out.println(i+" "+j+" "+y+" "+x); } color[i][j][1] = 0; } } for(int i = 0;i<H;i++){ for(int j = 0;j < W;j++){ color[i][j][1] = 0; } } if(c == redc){ count = 0; } } } if(count == 0){ System.out.println("YES"); }else{ System.out.println("NO"); } } } }