結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2022-06-13 13:05:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 185 ms / 3,000 ms |
コード長 | 982 bytes |
コンパイル時間 | 492 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 77,332 KB |
最終ジャッジ日時 | 2024-09-25 06:45:42 |
合計ジャッジ時間 | 5,777 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
import sys def input(): return sys.stdin.readline().strip() def main(): h, w = map(int, input().split()) s = [input() for _ in range(h)] if sum(sum(sij == "#" for sij in si) for si in s) == 0: return "NO" for dh in range(-h+1, h): for dw in range(-w+1, w): fail = False filled = [[0]*w for _ in range(h)] for i in range(h): for j in range(w): if not (s[i][j] == "#" and not filled[i][j]): continue filled[i][j] = True ii, jj = i+dh, j+dw if 0 <= ii < h and 0 <= jj < w and s[ii][jj] == "#" and not filled[ii][jj]: filled[ii][jj] = True else: fail = True break if fail: break else: return "YES" return "NO" print(main())