結果

問題 No.179 塗り分け
ユーザー maatanbetamaatanbeta
提出日時 2017-05-18 11:50:23
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 1,695 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 8,688 KB
最終ジャッジ日時 2023-07-26 16:50:59
合計ジャッジ時間 3,386 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 18 ms
8,488 KB
testcase_02 AC 17 ms
8,548 KB
testcase_03 AC 17 ms
8,476 KB
testcase_04 AC 17 ms
8,584 KB
testcase_05 AC 19 ms
8,400 KB
testcase_06 AC 17 ms
8,556 KB
testcase_07 AC 18 ms
8,508 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 19 ms
8,612 KB
testcase_11 AC 21 ms
8,572 KB
testcase_12 AC 24 ms
8,544 KB
testcase_13 AC 17 ms
8,440 KB
testcase_14 AC 18 ms
8,436 KB
testcase_15 AC 16 ms
8,428 KB
testcase_16 AC 16 ms
8,488 KB
testcase_17 AC 16 ms
8,436 KB
testcase_18 AC 19 ms
8,500 KB
testcase_19 AC 18 ms
8,536 KB
testcase_20 AC 19 ms
8,516 KB
testcase_21 AC 51 ms
8,596 KB
testcase_22 AC 132 ms
8,672 KB
testcase_23 AC 19 ms
8,428 KB
testcase_24 AC 145 ms
8,520 KB
testcase_25 AC 22 ms
8,640 KB
testcase_26 WA -
testcase_27 AC 35 ms
8,484 KB
testcase_28 WA -
testcase_29 AC 41 ms
8,516 KB
testcase_30 WA -
testcase_31 AC 39 ms
8,544 KB
testcase_32 WA -
testcase_33 AC 53 ms
8,432 KB
testcase_34 WA -
testcase_35 AC 57 ms
8,512 KB
testcase_36 AC 18 ms
8,612 KB
testcase_37 AC 17 ms
8,576 KB
testcase_38 AC 18 ms
8,544 KB
testcase_39 AC 19 ms
8,508 KB
testcase_40 AC 19 ms
8,444 KB
testcase_41 AC 18 ms
8,548 KB
testcase_42 AC 17 ms
8,432 KB
testcase_43 AC 18 ms
8,628 KB
testcase_44 AC 20 ms
8,388 KB
testcase_45 AC 19 ms
8,368 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")
for i in range(H-1, -1, -1):
    if "#" in S[i]:
        overy = H - i + 1
        break
while(y < H):
    x = 0
    while(x < W):
        if S[y][x] == "#":
            yi = 0
            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