結果
問題 |
No.179 塗り分け
|
ユーザー |
![]() |
提出日時 | 2025-03-26 15:45:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 908 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 94,364 KB |
最終ジャッジ日時 | 2025-03-26 15:46:24 |
合計ジャッジ時間 | 17,634 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 WA * 4 |
ソースコード
H, W = map(int, input().split()) grid = [input().strip() for _ in range(H)] black_cells = [(i, j) for i in range(H) for j in range(W) if grid[i][j] == '#'] n = len(black_cells) if n < 2: print("NO") exit() black_set = set(black_cells) dxdy = set() for i in range(n): ax, ay = black_cells[i] for j in range(n): if i != j: bx, by = black_cells[j] dx = bx - ax dy = by - ay dxdy.add((dx, dy)) found = False for dx, dy in dxdy: R = set() for (x, y) in black_cells: nx = x + dx ny = y + dy if (nx, ny) in black_set: R.add((x, y)) if not R: continue B = {(x + dx, y + dy) for (x, y) in R} if R & B: continue total = R.union(B) if len(total) == n and total == black_set: print("YES") found = True break if not found: print("NO")