結果

問題 No.179 塗り分け
ユーザー CsTarepanda
提出日時 2019-04-21 17:18:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-10-06 05:58:13
合計ジャッジ時間 16,384 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 31 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import copy
h, w = map(int, input().split())

field = [list(input()) for _ in range(h)]
black_n = "".join(map("".join, field)).count("#")

if black_n > 0 and black_n % 2:
    print("NO")
    exit()

def check(y, x):
    if field[y][x] != "#":
        return False
    m = copy.deepcopy(field)
    for red_y in range(h):
        for red_x in range(w):
            if m[red_y][red_x] == "#":
                m[red_y][red_x] = "@"
                nx = red_x + x
                ny = red_y + y
                if ny >= h or nx >= w or m[ny][nx] != "#":
                    return False
                m[ny][nx] = "@"
    return True



for i in range(h):
    for j in range(w):
        if check(i, j):
            print("YES")
            exit()
print("NO")
0