結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-05 22:37:26 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 528 ms / 3,000 ms |
| コード長 | 840 bytes |
| 記録 | |
| コンパイル時間 | 605 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 15,484 KB |
| 最終ジャッジ日時 | 2026-04-03 14:55:15 |
| 合計ジャッジ時間 | 10,599 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
H, W = map(int, input().split())
S = []
for i in range(H):
S.append([c for c in input()])
black = sum(S[i].count("#") for i in range(H))
if black % 2 == 1 or black == 0:
print("NO")
exit()
for h in range(H):
for w in range(-W + 1,W):
if h == 0 and w <= 0:
continue
s = [row[:] for row in S]
cnt = 0
flg = False
for i in range(H):
for j in range(W):
if s[i][j] == "#":
if 0 <= i + h <H and 0 <= j+w < W and s[i+h][j+w] == "#":
s[i][j] = "r"
s[i+h][j+w] = "b"
cnt += 2
else:
flg = True
if flg:
break
if cnt == black:
print("YES")
exit()
print("NO")