結果

問題 No.179 塗り分け
ユーザー matsu7874matsu7874
提出日時 2015-10-21 17:10:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 766 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,952 KB
最終ジャッジ日時 2024-04-10 12:47:02
合計ジャッジ時間 8,590 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
17,824 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 30 ms
11,136 KB
testcase_03 AC 28 ms
10,880 KB
testcase_04 AC 33 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 151 ms
10,880 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 29 ms
11,008 KB
testcase_09 AC 56 ms
11,008 KB
testcase_10 AC 1,706 ms
11,008 KB
testcase_11 AC 1,452 ms
11,008 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 #

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

cnt_black = sum(S[i].count('#') for i in range(H))
if cnt_black % 2 == 1 or cnt_black == 0:
    print('NO')
    exit()

for h in range(-H + 1, H):
    for w in range(-W + 1, W):
        if h == 0 and w == 0:
            continue
        s = [row[:] for row in S]
        cnt = 0
        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
        if cnt == cnt_black:
            print('YES')
            exit()
print('NO')
0