結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 119 ms
54,192 KB
testcase_02 AC 119 ms
53,912 KB
testcase_03 AC 117 ms
53,976 KB
testcase_04 WA -
testcase_05 AC 122 ms
53,892 KB
testcase_06 AC 111 ms
52,988 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 124 ms
53,924 KB
testcase_11 AC 111 ms
53,152 KB
testcase_12 AC 155 ms
54,080 KB
testcase_13 AC 119 ms
53,980 KB
testcase_14 AC 124 ms
53,900 KB
testcase_15 AC 121 ms
53,820 KB
testcase_16 WA -
testcase_17 AC 108 ms
53,064 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 123 ms
53,972 KB
testcase_21 AC 129 ms
53,920 KB
testcase_22 AC 154 ms
53,872 KB
testcase_23 AC 123 ms
54,080 KB
testcase_24 AC 144 ms
53,836 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 136 ms
53,880 KB
testcase_28 WA -
testcase_29 AC 127 ms
53,436 KB
testcase_30 WA -
testcase_31 AC 141 ms
53,544 KB
testcase_32 WA -
testcase_33 AC 161 ms
54,036 KB
testcase_34 WA -
testcase_35 AC 161 ms
54,092 KB
testcase_36 AC 107 ms
52,864 KB
testcase_37 AC 117 ms
54,000 KB
testcase_38 AC 115 ms
53,904 KB
testcase_39 AC 117 ms
53,928 KB
testcase_40 AC 117 ms
53,884 KB
testcase_41 AC 116 ms
54,100 KB
testcase_42 AC 116 ms
53,200 KB
testcase_43 AC 127 ms
54,288 KB
testcase_44 AC 130 ms
53,280 KB
testcase_45 AC 114 ms
53,028 KB
権限があれば一括ダウンロードができます

ソースコード

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