結果

問題 No.179 塗り分け
ユーザー とりすけとりすけ
提出日時 2023-05-02 01:06:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 773 ms / 3,000 ms
コード長 1,053 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 84,120 KB
最終ジャッジ日時 2023-08-13 03:37:33
合計ジャッジ時間 14,366 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,592 KB
testcase_01 AC 84 ms
71,412 KB
testcase_02 AC 83 ms
71,408 KB
testcase_03 AC 93 ms
71,604 KB
testcase_04 AC 87 ms
71,360 KB
testcase_05 AC 207 ms
81,436 KB
testcase_06 AC 86 ms
71,404 KB
testcase_07 AC 86 ms
75,804 KB
testcase_08 AC 376 ms
79,424 KB
testcase_09 AC 601 ms
82,612 KB
testcase_10 AC 94 ms
76,384 KB
testcase_11 AC 95 ms
76,576 KB
testcase_12 AC 545 ms
80,036 KB
testcase_13 AC 103 ms
77,384 KB
testcase_14 AC 100 ms
77,164 KB
testcase_15 AC 84 ms
71,560 KB
testcase_16 AC 84 ms
71,532 KB
testcase_17 AC 85 ms
71,556 KB
testcase_18 AC 112 ms
77,776 KB
testcase_19 AC 113 ms
77,800 KB
testcase_20 AC 597 ms
82,484 KB
testcase_21 AC 687 ms
82,160 KB
testcase_22 AC 773 ms
84,120 KB
testcase_23 AC 96 ms
76,628 KB
testcase_24 AC 725 ms
81,928 KB
testcase_25 AC 106 ms
77,808 KB
testcase_26 AC 418 ms
80,564 KB
testcase_27 AC 622 ms
81,928 KB
testcase_28 AC 394 ms
81,200 KB
testcase_29 AC 636 ms
82,500 KB
testcase_30 AC 513 ms
80,908 KB
testcase_31 AC 645 ms
81,376 KB
testcase_32 AC 184 ms
78,172 KB
testcase_33 AC 656 ms
81,240 KB
testcase_34 AC 421 ms
80,212 KB
testcase_35 AC 619 ms
82,796 KB
testcase_36 AC 85 ms
71,440 KB
testcase_37 AC 86 ms
71,444 KB
testcase_38 AC 88 ms
71,624 KB
testcase_39 AC 86 ms
71,356 KB
testcase_40 AC 89 ms
76,108 KB
testcase_41 AC 83 ms
71,420 KB
testcase_42 AC 88 ms
76,120 KB
testcase_43 AC 121 ms
78,124 KB
testcase_44 AC 194 ms
78,872 KB
testcase_45 AC 109 ms
77,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import copy

input = sys.stdin.readline

h, w = map(int, input().split())
s = [list(input().strip()) for i in range(h)]

c = 0
for i in range(h):
 for j in range(w):
  if s[i][j] == '#':
   c += 1

if c <= 1:
 print('NO', end='')
 exit()

for dy in range(h):
 for dx in range(w):
  if dy == 0 and dx == 0:
   continue
  sc = copy.deepcopy(s)
  flag = True
  for i in range(h):
   for j in range(w):
    if sc[i][j] == '#':
     if i + dy >= h or j + dx >= w or sc[i+dy][j+dx] == '.':
      flag = False
      break
     else:
      sc[i+dy][j+dx] = '.'
   if not flag:
    break
  if flag:
   print('YES', end='')
   exit()

for dy in range(h):
 for dx in range(w):
  if dy == 0 and dx == 0:
   continue
  sc = copy.deepcopy(s)
  flag = True
  for i in range(h):
   for j in range(w):
    if sc[i][w-j-1] == '#':
     if i + dy >= h or j + dx >= w or sc[i+dy][w-j-dx-1] == '.':
      flag = False
      break
     else:
      sc[i+dy][w-j-dx-1] = '.'
   if not flag:
    break
  if flag:
   print('YES', end='')
   exit()
print('NO', end='')
0