結果

問題 No.179 塗り分け
ユーザー kenkooookenkoooo
提出日時 2015-04-18 00:45:11
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,104 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 77,796 KB
実行使用メモリ 56,384 KB
最終ジャッジ日時 2024-04-10 12:11:49
合計ジャッジ時間 9,534 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
53,908 KB
testcase_01 AC 125 ms
54,036 KB
testcase_02 AC 127 ms
56,240 KB
testcase_03 WA -
testcase_04 AC 127 ms
54,116 KB
testcase_05 AC 131 ms
54,412 KB
testcase_06 AC 134 ms
54,376 KB
testcase_07 WA -
testcase_08 AC 135 ms
54,300 KB
testcase_09 AC 132 ms
53,980 KB
testcase_10 AC 134 ms
54,012 KB
testcase_11 AC 139 ms
54,356 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 131 ms
54,368 KB
testcase_15 AC 128 ms
54,288 KB
testcase_16 WA -
testcase_17 AC 130 ms
54,176 KB
testcase_18 AC 132 ms
54,168 KB
testcase_19 AC 133 ms
54,216 KB
testcase_20 AC 135 ms
54,264 KB
testcase_21 AC 124 ms
53,000 KB
testcase_22 WA -
testcase_23 AC 138 ms
54,056 KB
testcase_24 WA -
testcase_25 AC 133 ms
54,012 KB
testcase_26 AC 137 ms
54,256 KB
testcase_27 WA -
testcase_28 AC 136 ms
54,116 KB
testcase_29 WA -
testcase_30 AC 138 ms
53,792 KB
testcase_31 WA -
testcase_32 AC 120 ms
53,180 KB
testcase_33 WA -
testcase_34 AC 134 ms
54,088 KB
testcase_35 WA -
testcase_36 AC 126 ms
54,032 KB
testcase_37 AC 128 ms
54,264 KB
testcase_38 WA -
testcase_39 AC 114 ms
52,860 KB
testcase_40 WA -
testcase_41 AC 129 ms
54,036 KB
testcase_42 AC 130 ms
54,088 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 (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;
	}
}
0