結果

問題 No.179 塗り分け
ユーザー cmy
提出日時 2022-06-13 12:59:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 879 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-09-25 06:37:16
合計ジャッジ時間 3,951 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input():
    return sys.stdin.readline().strip()


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

    for dh in range(h):
        for dw in range(w):
            fail = False
            filled = [[0]*w for _ in range(h)]
            for i in range(h):
                for j in range(w):
                    if not (s[i][j] == "#" and not filled[i][j]):
                        continue
                    filled[i][j] = True

                    ii, jj = i+dh, j+dw
                    if ii < h and jj < w and s[ii][jj] == "#" and not filled[ii][jj]:
                        filled[ii][jj] = True
                    else:
                        fail = True
                        break
                if fail:
                    break
            else:
                return "YES"

    return "NO"


print(main())
0