結果

問題 No.179 塗り分け
ユーザー daku9640daku9640
提出日時 2018-05-29 23:49:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 702 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 12,176 KB
最終ジャッジ日時 2023-09-12 20:30:54
合計ジャッジ時間 6,124 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,176 KB
testcase_01 AC 15 ms
7,780 KB
testcase_02 AC 15 ms
7,848 KB
testcase_03 AC 15 ms
7,864 KB
testcase_04 AC 15 ms
7,832 KB
testcase_05 AC 15 ms
7,960 KB
testcase_06 AC 43 ms
8,284 KB
testcase_07 AC 15 ms
7,784 KB
testcase_08 AC 15 ms
7,880 KB
testcase_09 AC 16 ms
7,752 KB
testcase_10 AC 136 ms
8,520 KB
testcase_11 AC 726 ms
8,568 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = tuple(input() for _ in range(h))
    c_cnt = sum(a.count('#') for a in s)
    if c_cnt == 0 or c_cnt & 1:
        return "NO"
    m = {(i, j) for i in range(h) for j in range(w) if s[i][j] == '#'}
    a = min(m)
    m.remove(a)
    c_cnt = (c_cnt - 2) // 2
    for b in m:
        y = b[0] - a[0]
        x = b[1] - a[1]
        if f(m - {b}, y, x, c_cnt):
            return "YES"
    return "NO"
print(solve())
0