結果
| 問題 |
No.179 塗り分け
|
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 23:01:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 1,131 ms |
| コンパイル使用メモリ | 81,636 KB |
| 実行使用メモリ | 90,996 KB |
| 最終ジャッジ日時 | 2025-04-15 23:02:37 |
| 合計ジャッジ時間 | 18,004 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 36 WA * 4 |
ソースコード
H, W = map(int, input().split())
grid = [input().strip() for _ in range(H)]
blacks = []
for i in range(H):
for j in range(W):
if grid[i][j] == '#':
blacks.append((i, j))
if len(blacks) < 2:
print("NO")
exit()
blacks_set = set(blacks)
candidates = set()
# Generate all possible dx, dy from all pairs of black cells
for i in range(len(blacks)):
x1, y1 = blacks[i]
for j in range(len(blacks)):
if i == j:
continue
x2, y2 = blacks[j]
dx = x2 - x1
dy = y2 - y1
candidates.add((dx, dy))
found = False
for dx, dy in candidates:
if dx == 0 and dy == 0:
continue
R = set()
for (x, y) in blacks:
nx = x + dx
ny = y + dy
if (nx, ny) in blacks_set:
R.add((x, y))
if not R:
continue
B = set((x + dx, y + dy) for (x, y) in R)
# Check if R and B are disjoint and cover all blacks
if R.isdisjoint(B) and R.union(B) == blacks_set and len(B) > 0:
found = True
break
print("YES" if found else "NO")
lam6er