結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2015-03-26 19:22:06 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 203 ms / 3,000 ms |
コード長 | 1,159 bytes |
コンパイル時間 | 3,096 ms |
コンパイル使用メモリ | 77,368 KB |
実行使用メモリ | 54,176 KB |
最終ジャッジ日時 | 2024-07-23 14:24:25 |
合計ジャッジ時間 | 9,807 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
package division; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int w = sc.nextInt(); char[][] map = new char[h][]; for(int i=0;i<h;i++) { map[i] = sc.next().toCharArray(); } System.out.println(solve(h,w,map) ? "YES" : "NO"); } public static boolean solve(int h,int w,char[][] map) { boolean[][] painted = new boolean[h][w]; for(int di=0;di<h;di++) { LOOP: for(int dj=-w+1;dj<w;dj++) { if (di == 0 && dj <= 0) { continue; } for(int i=0;i<h;i++) { Arrays.fill(painted[i], false); } int count = 0; for(int i=0;i<h;i++) { for(int j=0;j<w;j++) { if (map[i][j] == '#' && !painted[i][j]) { int ni = i + di; int nj = j + dj; if (ni < 0 || ni >= h || nj < 0 || nj >= w) { continue LOOP; } if (map[ni][nj] != '#' || painted[i][j]) { continue LOOP; } painted[i][j] = painted[ni][nj] = true; count++; } } } if (count >= 1) { return true; } } } return false; } }