結果

問題 No.179 塗り分け
ユーザー MIKI Takushi
提出日時 2019-01-03 17:20:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 835 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-11-23 22:28:16
合計ジャッジ時間 38,241 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
from copy import deepcopy

h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]

def check(dh,dw):
    s2 = deepcopy(s)
    for hi in range(h):
        for wi in range(w):
            if h>hi+dh>=0 and w>wi+dw>=0:
                if s2[hi][wi]=="#" and s2[hi+dh][wi+dw]=="#":
                    s2[hi][wi] = "r"
                    s2[hi+dh][wi+dw] = "b"
                elif s2[hi][wi]=="#":
                    return False
            elif s2[hi][wi]=="#":
                return False
    for hi in range(h):
        for wi in range(w):
            if s2[hi][wi]=="#":
                return False
    return True

for dh in range(h):
    for dw in range(w):
        if dh==0 and dw==0:
            continue
        if check(dh,dw):
            print("YES")
            exit()
print("NO")
0