結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-29 23:38:45 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 724 bytes |
| コンパイル時間 | 314 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2024-06-30 08:05:27 |
| 合計ジャッジ時間 | 6,649 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 5 RE * 1 TLE * 1 -- * 33 |
ソースコード
def f(m, y, x, len_m):
for _ in range(len_m):
a = min(m)
ny = y + a[0]
nx = x + a[1]
if (ny, nx) not in m:
return False
m.remove(a)
m.remove((ny, nx))
return True
def solve():
h, w = map(int, input().split())
s = list(input() for _ in range(h))
if sum(a.count('#') for a in s) & 1:
return "NO"
m = set()
for i in range(h):
for j in range(w):
if s[i][j] == '#':
m.add((i, j))
len_m = (len(m) - 2) // 2
a = min(m)
m.remove(a)
for b in m:
y = b[0] - a[0]
x = b[1] - a[1]
if f(m - {b}, y, x, len_m):
return "YES"
return "NO"
print(solve())