結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2015-08-06 19:12:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 568 ms / 3,000 ms |
| コード長 | 1,522 bytes |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 77,520 KB |
| 実行使用メモリ | 55,976 KB |
| 最終ジャッジ日時 | 2024-07-23 14:32:25 |
| 合計ジャッジ時間 | 16,317 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
final int H = sc.nextInt();
final int W = sc.nextInt();
boolean[][] fields = new boolean[H][W];
for(int i = 0; i < H; i++){
char[] inputs = sc.next().toCharArray();
for(int j = 0; j < W; j++){
fields[i][j] = inputs[j] == '#';
}
}
boolean[][] checked = new boolean[H][W];
for(int dy = -(H - 1); dy < H; dy++){
for(int dx = -(W - 1); dx < W; dx++){
if(dx == 0 && dy == 0){ continue; }
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
checked[i][j] = false;
}
}
for(int y = 0; y < H; y++){
for(int x = 0; x < W; x++){
final int nx = x + dx;
final int ny = y + dy;
if(nx < 0 || nx >= W || ny < 0 || ny >= H){ continue; }
if(checked[y][x] || checked[ny][nx]){ continue; }
if(fields[y][x] && fields[ny][nx]){
checked[y][x] = checked[ny][nx] = true;
}
}
}
boolean found = false;
boolean flg = true;
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(fields[i][j]){ found = true; }
if(fields[i][j] && !checked[i][j]){
flg = false;
}
}
}
if(flg && found){
System.out.println("YES");
return;
}
}
}
System.out.println("NO");
}
}
uafr_cs