結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-07 00:04:50 |
| 言語 | Python3 (3.14.2 + numpy 2.4.0 + scipy 1.16.3) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,062 bytes |
| 記録 | |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-10-02 13:44:23 |
| 合計ジャッジ時間 | 2,717 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 3 |
| other | AC * 24 WA * 16 |
ソースコード
def read_data():
H, W = map(int, input().split())
S = [input() for i in range(H)]
return H, W, S
def solve(H, W, S):
Smat = [[c == '#' for c in row] for row in S]
if has_no_sharp(Smat):
return False
for h in range(H):
for w in range(W):
if h == w == 0:
continue
if can_be_painted(h, w, Smat, H, W):
return True
return False
def has_no_sharp(Smat):
for row in Smat:
if any(row):
return True
return False
def can_be_painted(h, w, Smat, H, W):
Scopy = [row[:] for row in Smat]
for x in range(H):
for y in range(W):
if Scopy[x][y]:
if x+h >= H or y+w >= W or not Scopy[x+h][y+w]:
return False
else:
Scopy[x+h][y+w] = False
return True
H, W, S = read_data()
if solve(H, W, S):
print("YES")
else:
Sreverse = [list(reversed(row)) for row in S]
if solve(H, W, Sreverse):
print("YES")
else:
print("NO")