結果

問題 No.179 塗り分け
ユーザー FromBooska
提出日時 2023-10-15 19:58:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,180 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2024-09-16 22:06:33
合計ジャッジ時間 8,545 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

# 黒を平行移動2グループに分けられるか
# 平行移動(di, dj)で全探索
# WA出た、djはマイナスもあるな
# 黒が0のときもダメだ、黒のカウントが2以上の偶数チェック必要

H, W = map(int, input().split())
S = []
S_num = []
black_count = 0
for i in range(H):
    temp = input()
    S.append(temp)
    black_count += temp.count('#')
    s = []
    for t in temp:
        if t == '.':
            s.append(0)
        else:
            s.append(1)
    S_num.append(s)
    
if black_count == 0 or black_count%2 == 1:
    print('NO')
    exit()

ans = 'NO'
for di in range(0, H):
    for dj in range(1-W, W):
        if (di, dj) == (0, 0):
            continue
        
        #print('di', di, 'dj', dj)
        color = [[0]*W for i in range(H)]
        for i in range(H):
            for j in range(W):
                #print('i', i, 'j', j)
                if S_num[i][j] == 1 and color[i][j] == 0:
                    if 0<=i+di<H and 0<=j+dj<W:
                        color[i][j] = 1
                        color[i+di][j+dj] = 1
        if S_num == color:
            #print(di, dj, color)
            ans = 'YES'
print(ans)   
0