結果

問題 No.179 塗り分け
ユーザー ichyo
提出日時 2015-04-05 23:40:56
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-10-02 13:15:52
合計ジャッジ時間 3,779 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())

grid = []
for y in range(H):
    grid.append(input())

def check(dx, dy):
    if dx == 0 and dy == 0:
        return False
    used = {}
    for y in range(H):
        for x in range(W):
            if grid[y][x] != '#':
                continue
            if (x, y) in used:
                continue
            used[(x, y)] = True
            ny = y + dy
            nx = x + dx
            if ny >= H or nx >= W or nx < 0 or ny < 0:
                return False
            if (nx, ny) in used:
                return False
            if grid[ny][nx] != '#':
                return False
            used[(nx, ny)] = True
    return True

ans = False

for dy in range(-H+1, H):
    for dx in range(-W+1, W):
        ans = ans or check(dx, dy)


print("YES" if ans else "NO")
0