結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-02 01:06:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 603 ms / 3,000 ms |
| コード長 | 1,053 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 82,012 KB |
| 実行使用メモリ | 81,220 KB |
| 最終ジャッジ日時 | 2024-11-20 20:11:57 |
| 合計ジャッジ時間 | 10,474 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
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='')