結果

問題 No.179 塗り分け
ユーザー goto_isyuku
提出日時 2017-06-17 17:56:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,486 ms / 3,000 ms
コード長 808 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 78,928 KB
最終ジャッジ日時 2024-07-23 14:43:45
合計ジャッジ時間 10,860 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections as cols

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

tiles = cols.OrderedDict()

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

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()
    ans_num = 0
    
    for t in tiles.keys():
      
      ot = (t[0] + v[0], t[1] + v[1])
      
      if t not in ans:
        if ot in tiles.keys():
          if ot not in ans:
            ans.add(t)
            ans.add(ot)
            ans_num += 2

    if tiles_num == ans_num:

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