結果

問題 No.179 塗り分け
ユーザー ssmkzk
提出日時 2019-03-02 19:50:55
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2024-06-23 12:28:22
合計ジャッジ時間 4,947 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1 -- * 3
other -- * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import sys

H, W = map(int, input().split())

black_l = []
count = 0

for i in range(H):
    l = list(input())
    for j in range(W):
        if l[j] == "#":
            black_l.append(str(i) + "-" + str(j))
            count += 1

if count % 2 == 0:
    num = count // 2
else:
    print("NO")
    sys.exit()

pattern_l = list(itertools.combinations(black_l, num))

# print(black_l)
#print(pattern_l)

for l_i in pattern_l:
    ck_l = set(l_i)
    mom_l = set(black_l)
    trans_l = list(mom_l - ck_l)
    for i in range(1,20):
        for j in range(20):
            nowck_l = list(ck_l)
            nowtrans_l = set(trans_l)
            dis = nowtrans_l
            for li in nowck_l:
                r , l = map(int, li.split("-"))
                r += i
                l += j
                puls = str(r) + "-" + str(l)
                #print(puls)
                dis.add(puls)
            if len(dis) == num:
                # print(i,j)
                # print(nowck_l)
                # print(nowtrans_l)
                print("YES")
                sys.exit()

print("NO")
sys.exit()
0