結果

問題 No.179 塗り分け
ユーザー maatanbetamaatanbeta
提出日時 2017-05-18 10:56:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,801 ms / 3,000 ms
コード長 1,243 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-14 06:27:47
合計ジャッジ時間 13,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 32 ms
11,008 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 32 ms
11,008 KB
testcase_05 AC 131 ms
11,008 KB
testcase_06 AC 32 ms
10,880 KB
testcase_07 AC 33 ms
11,008 KB
testcase_08 AC 34 ms
11,008 KB
testcase_09 AC 34 ms
11,008 KB
testcase_10 AC 34 ms
11,136 KB
testcase_11 AC 33 ms
11,136 KB
testcase_12 AC 1,801 ms
11,008 KB
testcase_13 AC 32 ms
10,880 KB
testcase_14 AC 33 ms
11,008 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 33 ms
11,008 KB
testcase_17 AC 32 ms
10,880 KB
testcase_18 AC 54 ms
11,008 KB
testcase_19 AC 52 ms
11,008 KB
testcase_20 AC 995 ms
11,008 KB
testcase_21 AC 223 ms
11,008 KB
testcase_22 AC 247 ms
11,136 KB
testcase_23 AC 33 ms
11,136 KB
testcase_24 AC 173 ms
11,008 KB
testcase_25 AC 39 ms
11,008 KB
testcase_26 AC 54 ms
11,136 KB
testcase_27 AC 662 ms
11,008 KB
testcase_28 AC 54 ms
11,008 KB
testcase_29 AC 1,007 ms
11,008 KB
testcase_30 AC 417 ms
11,008 KB
testcase_31 AC 1,222 ms
11,008 KB
testcase_32 AC 276 ms
11,008 KB
testcase_33 AC 1,240 ms
11,008 KB
testcase_34 AC 208 ms
11,008 KB
testcase_35 AC 1,437 ms
11,008 KB
testcase_36 AC 33 ms
11,008 KB
testcase_37 AC 34 ms
10,880 KB
testcase_38 AC 33 ms
10,880 KB
testcase_39 AC 33 ms
11,008 KB
testcase_40 AC 33 ms
10,880 KB
testcase_41 AC 32 ms
10,880 KB
testcase_42 AC 32 ms
10,880 KB
testcase_43 AC 54 ms
10,880 KB
testcase_44 AC 147 ms
10,880 KB
testcase_45 AC 36 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy


def search(yi, xi):
    SC = deepcopy(S)
    yt = 0
    while(yt < H):
        xt = 0
        while(xt < W):
            if SC[yt][xt] == "#":
                try:
                    if SC[yt+yi][xt+xi] == "#":
                        SC[yt+yi][xt+xi] = "$"
                    else:
                        return False
                except IndexError:
                    return False
            xt += 1
        yt += 1
    return True


H, W = list(map(int, input().split()))
S = [0] * H
for i in range(H):
    S[i] = list(input())
printed = False
y = 0
while(y < H):
    x = 0
    while(x < W):
        if S[y][x] == "#":
            yi = -y
            while(y + yi < H):
                xi = -x
                while(x + xi < W):
                    if yi != 0 or xi != 0:
                        if S[y+yi][x+xi] == "#":
                            if search(yi, xi):
                                yi, xi = float("inf"), float("inf")
                                print("YES")
                                printed = True
                    xi += 1
                yi += 1
            y, x = float("inf"), float("inf")
        x += 1
    y += 1
    if y >= H and not printed:
        print("NO")
0