結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
nisizawa
|
| 提出日時 | 2017-12-11 19:44:49 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 346 ms / 3,000 ms |
| + 926µs | |
| コード長 | 908 bytes |
| 記録 | |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 21,412 KB |
| 実行使用メモリ | 15,868 KB |
| 最終ジャッジ日時 | 2026-08-24 03:24:38 |
| 合計ジャッジ時間 | 8,323 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
def solve(h, w, map_ls):
ct = map_ls.count('#')
if ct == 0 or ct % 2 == 1:
return 'NO'
for dx in range(-(w - 1), w):
for dy in range(h):
if dx <= 0 and dy == 0:
continue
memo = [c for c in map_ls]
for i_s, m in enumerate(memo):
if m == '.':
continue
sx, sy = i_s % w, i_s // w
gx, gy = sx + dx, sy + dy
i_g = w * gy + gx
if not (0 <= gx < w and 0 <= gy < h):
break
if not memo[i_g] == '#':
break
memo[i_s] = '.'
memo[i_g] = '.'
else:
if not '#' in memo:
return 'YES'
return 'NO'
h, w = map(int, input().split())
map_ls = [c for i in range(h) for c in input()]
print(solve(h, w, map_ls))
nisizawa