結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
AEn
|
| 提出日時 | 2022-05-13 14:13:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 335 ms / 3,000 ms |
| コード長 | 1,045 bytes |
| コンパイル時間 | 2,321 ms |
| コンパイル使用メモリ | 81,664 KB |
| 実行使用メモリ | 77,592 KB |
| 最終ジャッジ日時 | 2024-07-21 12:15:57 |
| 合計ジャッジ時間 | 5,953 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
H, W = map(int, input().split())
c = []
cnt = 0
for _ in range(H):
s = list(input())
cnt += s.count('#')
c.append(s)
if cnt == 0 or cnt%2==1:
print('NO')
exit()
def solve(i, j):
w1, w2 = [], []
w1.append([0, H, 1])
w2.append([0, W, 1])
w1.append([H-1, -1, -1])
w2.append([W-1, -1, -1])
p, q = w1[i<0], w2[j<0]
b = set()
for x in range(p[0], p[1], p[2]):
for y in range(q[0], q[1], q[2]):
if x+i<0 or x+i>H-1 or y+j<0 or y+j>W-1:
if (x, y) not in b and c[x][y]=='#':
return False
else:
continue
if (x, y) in b or c[x][y] == '.':
continue
b.add((x, y))
if c[x+i][y+j]=='.':
return False
else:
b.add((x+i, y+j))
return True
for i in range(-H+1, H):
for j in range(-W+1, W):
if i == j == 0:
continue
if solve(i, j):
print('YES')
exit()
print('NO')
AEn