結果

問題 No.179 塗り分け
ユーザー masayamatumasayamatu
提出日時 2020-05-05 22:37:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 684 ms / 3,000 ms
コード長 840 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,992 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2023-09-30 21:27:06
合計ジャッジ時間 4,410 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,244 KB
testcase_01 AC 17 ms
8,376 KB
testcase_02 AC 16 ms
8,164 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
8,328 KB
testcase_05 AC 15 ms
8,208 KB
testcase_06 AC 16 ms
8,308 KB
testcase_07 AC 15 ms
8,380 KB
testcase_08 AC 124 ms
8,312 KB
testcase_09 AC 120 ms
8,280 KB
testcase_10 AC 16 ms
8,424 KB
testcase_11 AC 18 ms
8,212 KB
testcase_12 AC 225 ms
8,264 KB
testcase_13 AC 17 ms
7,860 KB
testcase_14 AC 16 ms
7,880 KB
testcase_15 AC 15 ms
8,236 KB
testcase_16 AC 15 ms
8,212 KB
testcase_17 AC 15 ms
8,248 KB
testcase_18 AC 19 ms
8,416 KB
testcase_19 AC 18 ms
8,276 KB
testcase_20 AC 16 ms
8,232 KB
testcase_21 AC 15 ms
8,392 KB
testcase_22 AC 684 ms
8,368 KB
testcase_23 AC 16 ms
8,244 KB
testcase_24 AC 152 ms
8,304 KB
testcase_25 AC 16 ms
8,316 KB
testcase_26 AC 30 ms
8,440 KB
testcase_27 AC 130 ms
8,344 KB
testcase_28 AC 20 ms
8,332 KB
testcase_29 AC 139 ms
8,300 KB
testcase_30 AC 63 ms
8,444 KB
testcase_31 AC 144 ms
8,372 KB
testcase_32 AC 53 ms
8,380 KB
testcase_33 AC 150 ms
8,400 KB
testcase_34 AC 42 ms
8,420 KB
testcase_35 AC 167 ms
8,372 KB
testcase_36 AC 15 ms
7,824 KB
testcase_37 AC 15 ms
8,364 KB
testcase_38 AC 15 ms
7,860 KB
testcase_39 AC 15 ms
7,960 KB
testcase_40 AC 16 ms
7,788 KB
testcase_41 AC 15 ms
8,324 KB
testcase_42 AC 15 ms
7,792 KB
testcase_43 AC 20 ms
7,928 KB
testcase_44 AC 37 ms
7,864 KB
testcase_45 AC 18 ms
7,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append([c for c in input()])

black = sum(S[i].count("#") for i in range(H))

if black % 2 == 1 or black == 0:
    print("NO")
    exit()
for h in range(H):
    for w in range(-W + 1,W):
        if h == 0 and w <= 0:
            continue
        s = [row[:] for row in S]
        cnt = 0
        flg = False
        for i in range(H):
            for j in range(W):
                if s[i][j] == "#":
                    if 0 <= i + h <H and 0 <= j+w < W and s[i+h][j+w] == "#":
                        s[i][j] = "r"
                        s[i+h][j+w] = "b"
                        cnt += 2
                    else:
                        flg = True
            if flg:
                break
        if cnt == black:
            print("YES")
            exit()
print("NO")
0