結果

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

ソースコード

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))
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