結果

問題 No.179 塗り分け
ユーザー 👑 SPD_9X2
提出日時 2025-07-13 17:22:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 743 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 76,088 KB
最終ジャッジ日時 2025-07-13 17:22:28
合計ジャッジ時間 4,806 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/179

ずらし方全探索

"""

import sys

def check(dx,dy):
    
    for i in range(H):
        for j in range(W):

            if S[i][j] == ".":
                continue

            cnt = 0

            if 0 <= i+dx < H and 0 <= j+dy < W and S[i+dx][j+dy] == "#":
                cnt += 1
            if 0 <= i-dx < H and 0 <= j-dy < W and S[i-dx][j-dy] == "#":
                cnt += 1

            if cnt != 1:
                return False

    return True
            

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

S = [ input() for i in range(H) ]

for dx in range(51):

    for dy in range(-50,51):

        if check(dx,dy):
            print ("YES")
            sys.exit()

print ("NO")

                
0