結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2022-01-30 09:45:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,206 ms / 3,000 ms |
コード長 | 784 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 81,836 KB |
実行使用メモリ | 81,744 KB |
最終ジャッジ日時 | 2024-06-11 08:10:06 |
合計ジャッジ時間 | 28,447 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
import copy def check(dy, dx): T = copy.deepcopy(S) paint = False for y in range(H): for x in range(W): if T[y][x]: if 0 <= y + dy < H and 0 <= x + dx < W and T[y + dy][x + dx]: T[y + dy][x + dx] = 0 paint = True else: return 0 return paint H, W = map(int, input().split()) S = [[1 if x == "#" else 0 for x in input()] for _ in range(H)] ok = False for dy in range(H): for dx in range(W): if dy == dx == 0: continue ok |= check(dy, dx) S = [*map(lambda x: x[::-1], S)] for dy in range(H): for dx in range(W): if dy == dx == 0: continue ok |= check(dy, dx) print("YES" if ok else "NO")