結果

問題 No.179 塗り分け
ユーザー cmycmy
提出日時 2022-06-13 13:05:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 3,000 ms
コード長 982 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 76,832 KB
最終ジャッジ日時 2023-10-25 22:30:14
合計ジャッジ時間 5,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,536 KB
testcase_01 AC 37 ms
53,536 KB
testcase_02 AC 34 ms
53,536 KB
testcase_03 AC 34 ms
53,536 KB
testcase_04 AC 35 ms
53,536 KB
testcase_05 AC 73 ms
75,732 KB
testcase_06 AC 49 ms
70,304 KB
testcase_07 AC 39 ms
59,412 KB
testcase_08 AC 98 ms
76,424 KB
testcase_09 AC 103 ms
76,364 KB
testcase_10 AC 80 ms
76,072 KB
testcase_11 AC 76 ms
75,952 KB
testcase_12 AC 107 ms
76,288 KB
testcase_13 AC 37 ms
53,536 KB
testcase_14 AC 39 ms
59,332 KB
testcase_15 AC 35 ms
53,536 KB
testcase_16 AC 34 ms
53,536 KB
testcase_17 AC 34 ms
53,536 KB
testcase_18 AC 81 ms
75,920 KB
testcase_19 AC 81 ms
75,852 KB
testcase_20 AC 109 ms
76,428 KB
testcase_21 AC 128 ms
76,832 KB
testcase_22 AC 169 ms
76,628 KB
testcase_23 AC 78 ms
75,928 KB
testcase_24 AC 111 ms
76,596 KB
testcase_25 AC 77 ms
75,848 KB
testcase_26 AC 86 ms
76,020 KB
testcase_27 AC 113 ms
76,648 KB
testcase_28 AC 84 ms
76,112 KB
testcase_29 AC 109 ms
76,540 KB
testcase_30 AC 102 ms
76,392 KB
testcase_31 AC 116 ms
76,632 KB
testcase_32 AC 91 ms
76,224 KB
testcase_33 AC 108 ms
76,556 KB
testcase_34 AC 90 ms
76,204 KB
testcase_35 AC 107 ms
76,492 KB
testcase_36 AC 36 ms
53,536 KB
testcase_37 AC 35 ms
53,536 KB
testcase_38 AC 34 ms
53,536 KB
testcase_39 AC 34 ms
53,536 KB
testcase_40 AC 35 ms
53,536 KB
testcase_41 AC 34 ms
53,536 KB
testcase_42 AC 33 ms
53,536 KB
testcase_43 AC 48 ms
70,312 KB
testcase_44 AC 65 ms
75,656 KB
testcase_45 AC 42 ms
61,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]

    if sum(sum(sij == "#" for sij in si) for si in s) == 0:
        return "NO"

    for dh in range(-h+1, h):
        for dw in range(-w+1, w):
            fail = False
            filled = [[0]*w for _ in range(h)]
            for i in range(h):
                for j in range(w):
                    if not (s[i][j] == "#" and not filled[i][j]):
                        continue
                    filled[i][j] = True

                    ii, jj = i+dh, j+dw
                    if 0 <= ii < h and 0 <= jj < w and s[ii][jj] == "#" and not filled[ii][jj]:
                        filled[ii][jj] = True
                    else:
                        fail = True
                        break
                if fail:
                    break
            else:
                return "YES"

    return "NO"


print(main())
0