結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
kenkoooo
|
| 提出日時 | 2015-04-18 00:49:07 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,153 bytes |
| 記録 | |
| コンパイル時間 | 2,214 ms |
| コンパイル使用メモリ | 77,420 KB |
| 実行使用メモリ | 41,520 KB |
| 最終ジャッジ日時 | 2024-10-02 14:12:42 |
| 合計ジャッジ時間 | 9,610 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 2 |
| other | AC * 28 WA * 12 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int H = sc.nextInt();
int W = sc.nextInt();
char[][] map = new char[H][];
for (int i = 0; i < map.length; i++) {
map[i] = sc.next().toCharArray();
}
int cnt = 0;
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[i].length; j++) {
if (map[i][j] == '#') {
cnt++;
}
}
}
if (cnt % 2 == 1) {
System.out.println("NO");
return;
}
for (int x = 0; x < H - 1; x++) {
for (int y = 0; y < W - 1; y++) {
if (x == 0 && y == 0) {
continue;
}
if (check(x, y, map)) {
System.out.println("YES");
return;
}
}
}
System.out.println("NO");
}
static boolean check(int x, int y, char[][] map) {
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map[i].length; j++) {
int h = i + x;
int w = j + y;
if (map[i][j] == '#') {
if (h >= map.length || w >= map[i].length || map[h][w] != '#') {
return false;
}
map[i][j] = '.';
map[h][w] = '.';
}
}
}
return true;
}
}
kenkoooo