結果

問題 No.179 塗り分け
コンテスト
ユーザー cmy
提出日時 2022-06-13 12:59:08
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 879 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 130 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 81,168 KB
最終ジャッジ日時 2026-04-12 11:07:34
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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