結果

問題 No.179 塗り分け
ユーザー MIKI TakushiMIKI Takushi
提出日時 2019-01-03 17:54:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 457 ms / 3,000 ms
コード長 908 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 10,800 KB
実行使用メモリ 8,676 KB
最終ジャッジ日時 2023-09-30 21:07:04
合計ジャッジ時間 5,174 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,460 KB
testcase_01 AC 18 ms
8,440 KB
testcase_02 AC 18 ms
8,456 KB
testcase_03 AC 18 ms
8,480 KB
testcase_04 AC 18 ms
8,492 KB
testcase_05 AC 45 ms
8,464 KB
testcase_06 AC 18 ms
8,468 KB
testcase_07 AC 18 ms
8,520 KB
testcase_08 AC 19 ms
8,428 KB
testcase_09 AC 19 ms
8,372 KB
testcase_10 AC 20 ms
8,536 KB
testcase_11 AC 20 ms
8,524 KB
testcase_12 AC 457 ms
8,536 KB
testcase_13 AC 18 ms
8,372 KB
testcase_14 AC 18 ms
8,440 KB
testcase_15 AC 18 ms
8,488 KB
testcase_16 AC 17 ms
8,372 KB
testcase_17 AC 18 ms
8,524 KB
testcase_18 AC 24 ms
8,500 KB
testcase_19 AC 23 ms
8,448 KB
testcase_20 AC 257 ms
8,572 KB
testcase_21 AC 69 ms
8,376 KB
testcase_22 AC 79 ms
8,540 KB
testcase_23 AC 19 ms
8,512 KB
testcase_24 AC 54 ms
8,536 KB
testcase_25 AC 20 ms
8,524 KB
testcase_26 AC 24 ms
8,540 KB
testcase_27 AC 183 ms
8,596 KB
testcase_28 AC 25 ms
8,556 KB
testcase_29 AC 268 ms
8,480 KB
testcase_30 AC 116 ms
8,508 KB
testcase_31 AC 325 ms
8,452 KB
testcase_32 AC 81 ms
8,580 KB
testcase_33 AC 323 ms
8,620 KB
testcase_34 AC 62 ms
8,572 KB
testcase_35 AC 376 ms
8,676 KB
testcase_36 AC 19 ms
8,484 KB
testcase_37 AC 17 ms
8,400 KB
testcase_38 AC 17 ms
8,344 KB
testcase_39 AC 17 ms
8,264 KB
testcase_40 AC 18 ms
8,268 KB
testcase_41 AC 18 ms
8,436 KB
testcase_42 AC 17 ms
8,332 KB
testcase_43 AC 23 ms
8,464 KB
testcase_44 AC 50 ms
8,556 KB
testcase_45 AC 19 ms
8,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
from copy import deepcopy

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

def check(dh,dw):
    s2 = [[1 if s[hi][wi]=="#" else 0 for wi in range(w)] for hi in range(h)]
    for hi in range(h):
        for wi in range(w):
            if s2[hi][wi]==1:
                if h>hi+dh>=0 and w>wi+dw>=0:
                    if s2[hi+dh][wi+dw]==1:
                        s2[hi][wi] = 2
                        s2[hi+dh][wi+dw] = 3
                    else:
                        return False
                else:
                    return False
    return True

black = []
for hi in range(h):
    for wi in range(w):
        if s[hi][wi]=="#":
            black.append((hi,wi))
if len(black)>0:
    hi,wi = black[0]
    for i in range(1,len(black)):
        hi2,wi2 = black[i]
        if check(hi2-hi, wi2-wi):
            print("YES")
            exit()
print("NO")
0