結果

問題 No.179 塗り分け
ユーザー 回転
提出日時 2025-09-10 22:46:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2025-09-10 22:46:13
合計ジャッジ時間 5,269 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 38 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = list(map(int,input().split()))
S = [input() for _ in range(H)]
if(sum(S[i][j] == "#" for j in range(W) for i in range(H))%2 == 1):
    print("NO")
    exit()

def check(ys,xs):
    if(ys == 0 and xs == 3):
        pass
    looked = set()
    for i in range(H):
        for j in range(W):
            if(S[i][j] == "."):continue
            if((i,j) in looked):continue
            looked.add((i,j))
            next_y = i + ys
            next_x = j + xs
            if(next_y < 0 or H <= next_y):return False
            if(next_x < 0 or W <= next_x):return False
            if(S[next_y][next_x] == "."):return False
            looked.add((next_y,next_x))
    return True

for y_shift in range(-H,H+1):
    for x_shift in range(-W,W+1):
        if(y_shift == x_shift == 0):continue
        if(check(y_shift,x_shift)):
            print("YES")
            exit()
print("NO")
0