結果

問題 No.179 塗り分け
ユーザー MIKI TakushiMIKI Takushi
提出日時 2019-01-03 17:48:22
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 1,618 ms / 3,000 ms
コード長 902 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 8,740 KB
最終ジャッジ日時 2023-08-15 14:55:53
合計ジャッジ時間 11,362 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,396 KB
testcase_01 AC 17 ms
8,432 KB
testcase_02 AC 18 ms
8,400 KB
testcase_03 AC 18 ms
8,508 KB
testcase_04 AC 18 ms
8,516 KB
testcase_05 AC 104 ms
8,444 KB
testcase_06 AC 18 ms
8,484 KB
testcase_07 AC 18 ms
8,412 KB
testcase_08 AC 19 ms
8,488 KB
testcase_09 AC 20 ms
8,492 KB
testcase_10 AC 20 ms
8,704 KB
testcase_11 AC 21 ms
8,728 KB
testcase_12 AC 1,618 ms
8,732 KB
testcase_13 AC 17 ms
8,532 KB
testcase_14 AC 17 ms
8,480 KB
testcase_15 AC 16 ms
8,404 KB
testcase_16 AC 16 ms
8,444 KB
testcase_17 AC 18 ms
8,536 KB
testcase_18 AC 37 ms
8,588 KB
testcase_19 AC 37 ms
8,524 KB
testcase_20 AC 879 ms
8,640 KB
testcase_21 AC 184 ms
8,600 KB
testcase_22 AC 202 ms
8,576 KB
testcase_23 AC 18 ms
8,656 KB
testcase_24 AC 145 ms
8,504 KB
testcase_25 AC 24 ms
8,596 KB
testcase_26 AC 38 ms
8,616 KB
testcase_27 AC 577 ms
8,612 KB
testcase_28 AC 35 ms
8,528 KB
testcase_29 AC 864 ms
8,524 KB
testcase_30 AC 353 ms
8,540 KB
testcase_31 AC 1,086 ms
8,732 KB
testcase_32 AC 241 ms
8,696 KB
testcase_33 AC 1,107 ms
8,632 KB
testcase_34 AC 179 ms
8,564 KB
testcase_35 AC 1,317 ms
8,740 KB
testcase_36 AC 18 ms
8,404 KB
testcase_37 AC 17 ms
8,400 KB
testcase_38 AC 17 ms
8,404 KB
testcase_39 AC 17 ms
8,384 KB
testcase_40 AC 17 ms
8,568 KB
testcase_41 AC 16 ms
8,392 KB
testcase_42 AC 17 ms
8,544 KB
testcase_43 AC 36 ms
8,548 KB
testcase_44 AC 119 ms
8,480 KB
testcase_45 AC 20 ms
8,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

def check(dh,dw):
    s2 = deepcopy(s)
    cnt = 0
    for hi in range(h):
        for wi in range(w):
            if s2[hi][wi]=="#":
                cnt += 1
                if h>hi+dh>=0 and w>wi+dw>=0:
                    if s2[hi+dh][wi+dw]=="#":
                        s2[hi][wi] = "r"
                        s2[hi+dh][wi+dw] = "b"
                    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