結果

問題 No.179 塗り分け
ユーザー ichyoichyo
提出日時 2015-04-05 23:44:20
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 939 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 12,840 KB
最終ジャッジ日時 2023-07-25 19:34:25
合計ジャッジ時間 8,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,256 KB
testcase_01 AC 17 ms
7,836 KB
testcase_02 AC 17 ms
7,804 KB
testcase_03 AC 16 ms
7,908 KB
testcase_04 AC 16 ms
7,720 KB
testcase_05 AC 429 ms
8,164 KB
testcase_06 AC 124 ms
8,288 KB
testcase_07 WA -
testcase_08 AC 18 ms
7,892 KB
testcase_09 AC 43 ms
7,892 KB
testcase_10 AC 1,610 ms
8,584 KB
testcase_11 AC 1,364 ms
8,368 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 #

H, W = map(int, input().split())

grid = []
for y in range(H):
    grid.append(input())

def check(dx, dy):
    if dx == 0 and dy == 0:
        return False

    used = {}
    for y in range(H):
        for x in range(W):
            ny = y + dy
            nx = x + dx
            if grid[y][x] != '#':
                continue
            if (x, y) in used:
                continue
            if ny >= H or nx >= W or nx < 0 or ny < 0:
                continue
            if (nx, ny) in used:
                continue
            if grid[ny][nx] != '#':
                continue
            used[(x, y)] = True
            used[(nx, ny)] = True
    for y in range(H):
        for x in range(W):
            if grid[y][x] == '#' and not (x, y) in used:
                return False
    return True

ans = False

for dy in range(-H+1, H):
    for dx in range(-W+1, W):
        ans = ans or check(dx, dy)


print("YES" if ans else "NO")
0