結果

問題 No.179 塗り分け
ユーザー maatanbetamaatanbeta
提出日時 2017-05-18 11:13:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 999 ms / 3,000 ms
コード長 1,605 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 8,692 KB
最終ジャッジ日時 2023-09-30 20:54:57
合計ジャッジ時間 6,700 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
8,632 KB
testcase_01 AC 21 ms
8,612 KB
testcase_02 AC 19 ms
8,400 KB
testcase_03 AC 19 ms
8,584 KB
testcase_04 AC 19 ms
8,584 KB
testcase_05 AC 113 ms
8,504 KB
testcase_06 AC 19 ms
8,404 KB
testcase_07 AC 20 ms
8,580 KB
testcase_08 AC 21 ms
8,452 KB
testcase_09 AC 22 ms
8,564 KB
testcase_10 AC 20 ms
8,592 KB
testcase_11 AC 20 ms
8,516 KB
testcase_12 AC 37 ms
8,604 KB
testcase_13 AC 19 ms
8,512 KB
testcase_14 AC 20 ms
8,520 KB
testcase_15 AC 19 ms
8,440 KB
testcase_16 AC 19 ms
8,536 KB
testcase_17 AC 19 ms
8,584 KB
testcase_18 AC 22 ms
8,532 KB
testcase_19 AC 22 ms
8,484 KB
testcase_20 AC 22 ms
8,636 KB
testcase_21 AC 199 ms
8,672 KB
testcase_22 AC 139 ms
8,660 KB
testcase_23 AC 20 ms
8,616 KB
testcase_24 AC 151 ms
8,484 KB
testcase_25 AC 25 ms
8,508 KB
testcase_26 AC 32 ms
8,532 KB
testcase_27 AC 527 ms
8,512 KB
testcase_28 AC 38 ms
8,532 KB
testcase_29 AC 425 ms
8,496 KB
testcase_30 AC 262 ms
8,676 KB
testcase_31 AC 999 ms
8,660 KB
testcase_32 AC 252 ms
8,496 KB
testcase_33 AC 546 ms
8,596 KB
testcase_34 AC 149 ms
8,692 KB
testcase_35 AC 460 ms
8,560 KB
testcase_36 AC 19 ms
8,632 KB
testcase_37 AC 19 ms
8,600 KB
testcase_38 AC 19 ms
8,428 KB
testcase_39 AC 19 ms
8,436 KB
testcase_40 AC 19 ms
8,600 KB
testcase_41 AC 19 ms
8,468 KB
testcase_42 AC 19 ms
8,592 KB
testcase_43 AC 30 ms
8,416 KB
testcase_44 AC 75 ms
8,632 KB
testcase_45 AC 20 ms
8,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy


def search(yi, xi):
    global overy
    global overx
    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:
                    if yt+yi >= H:
                        overy = yi
                    if xt+xi >= W:
                        overx = xi
                    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
overy, overx = float("inf"), float("inf")
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
                    if overx < xi:
                        xi = float("inf")
                yi += 1
                if overy < yi:
                    yi = float("inf")
            y, x = float("inf"), float("inf")
        x += 1
    y += 1
    if y >= H and not printed:
        print("NO")
0