結果

問題 No.179 塗り分け
ユーザー matsu7874
提出日時 2015-10-21 17:04:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 18,080 KB
最終ジャッジ日時 2024-10-02 14:46:30
合計ジャッジ時間 11,728 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 4
other WA * 5 TLE * 2 -- * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append([c for c in input()])

cnt_black = sum(S[i].count('#') for i in range(H))
if cnt_black % 2 == 1:
    print('NO')
    exit()

print(S)
for h in range(-H + 1, H):
    for w in range(-W + 1, W):
        if h == 0 and w == 0:
            continue
        s = copy.deepcopy(S)
        cnt = 0
        for i in range(H):
            for j in range(W):
                if s[i][j] == '#':
                    if 0 <= i + h < H and 0 <= j + w < W and s[i + h][j + w] == '#':
                        s[i][j] = 'r'
                        s[i + h][j + w] = 'b'
                        cnt += 2
        if cnt == cnt_black:
            print('YES')
            exit()
print('NO')
0