結果

問題 No.179 塗り分け
ユーザー goto_isyuku
提出日時 2017-06-17 16:16:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 716 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,376 KB
最終ジャッジ日時 2024-10-03 04:04:41
合計ジャッジ時間 4,724 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5 TLE * 1
other -- * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import gc

gc.disable()

h, w = [int(x) for x in input().split()]

tiles = []

for i in range(h):
  l = input()
  for j in range(w):
    if l[j] == "#":
      tiles.append((i, j))

vec = []

for i in range(h):
  for j in range(-1 * w + 1 ,w):
    vec.append((i, j))

del vec[vec.index((0, 0))]

tiles_num = len(tiles)
      
if tiles_num == 0:
  print("NO")
else:
  
  result = False
  
  for v in vec:
    ans = set()
    
    for t in tiles:
      
      ot = (t[0] + v[0], t[1] + v[1])
      
      if t not in ans and ot in tiles and ot not in ans:
        ans.add(t)
        ans.add(ot)
    
    if tiles_num == len(ans):

      result = True
      break
  
  if result:
    print("YES")
  else:
    print("NO")
0