結果

問題 No.179 塗り分け
ユーザー 回転
提出日時 2025-09-10 22:47:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 82,308 KB
実行使用メモリ 62,324 KB
最終ジャッジ日時 2025-09-10 22:47:12
合計ジャッジ時間 4,076 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 3
other AC * 25 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = list(map(int,input().split()))
S = [input() for _ in range(H)]
black = sum(S[i][j] == "#" for j in range(W) for i in range(H))%2
if(black%2 == 1 or black == 0):
    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