結果

問題 No.179 塗り分け
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-04-28 20:23:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 956 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 77,040 KB
最終ジャッジ日時 2024-04-14 06:03:17
合計ジャッジ時間 5,083 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,408 KB
testcase_01 AC 37 ms
53,624 KB
testcase_02 AC 38 ms
52,872 KB
testcase_03 AC 37 ms
53,088 KB
testcase_04 AC 37 ms
53,336 KB
testcase_05 AC 73 ms
76,344 KB
testcase_06 AC 56 ms
72,972 KB
testcase_07 WA -
testcase_08 AC 118 ms
76,328 KB
testcase_09 AC 113 ms
76,496 KB
testcase_10 AC 86 ms
76,688 KB
testcase_11 AC 83 ms
76,496 KB
testcase_12 AC 121 ms
76,504 KB
testcase_13 AC 40 ms
54,316 KB
testcase_14 AC 42 ms
60,200 KB
testcase_15 AC 37 ms
52,864 KB
testcase_16 AC 38 ms
53,020 KB
testcase_17 WA -
testcase_18 AC 88 ms
76,368 KB
testcase_19 AC 91 ms
76,284 KB
testcase_20 AC 124 ms
76,600 KB
testcase_21 AC 133 ms
76,584 KB
testcase_22 AC 175 ms
76,320 KB
testcase_23 AC 92 ms
76,160 KB
testcase_24 AC 118 ms
76,256 KB
testcase_25 AC 95 ms
76,252 KB
testcase_26 AC 92 ms
76,184 KB
testcase_27 AC 111 ms
76,812 KB
testcase_28 AC 89 ms
76,052 KB
testcase_29 AC 128 ms
76,632 KB
testcase_30 AC 102 ms
76,424 KB
testcase_31 AC 115 ms
76,376 KB
testcase_32 AC 100 ms
76,404 KB
testcase_33 AC 126 ms
77,040 KB
testcase_34 AC 99 ms
76,460 KB
testcase_35 AC 122 ms
76,460 KB
testcase_36 AC 38 ms
53,496 KB
testcase_37 AC 38 ms
52,828 KB
testcase_38 AC 38 ms
52,436 KB
testcase_39 AC 41 ms
52,856 KB
testcase_40 AC 38 ms
52,684 KB
testcase_41 AC 37 ms
52,792 KB
testcase_42 AC 37 ms
54,132 KB
testcase_43 AC 53 ms
71,136 KB
testcase_44 AC 74 ms
76,048 KB
testcase_45 AC 47 ms
62,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def inside(x, y):
    return 0 <= x < H and 0 <= y < W

def move(h, w):
    c = [[-1] * W for i in range(H)]
    for i in range(H):
        for j in range(W):
            # まだ塗られていない黒マスが見つかったら
            if s[i][j] == '#' and c[i][j] == -1:
                # このマスを赤に塗る
                c[i][j] = 0
                # 対応する黒マスがなければやめる
                ni = i + h; nj = j + w
                if not inside(ni, nj):
                    return False
                if s[ni][nj] != '#':
                    return False
                # 対応するマスを青に
                c[ni][nj] = 1

    return True


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

for h in range(-H, H):
    for w in range(-W, W):
        if h == w == 0:
            continue
        if move(h, w):
            print("YES")
            exit()
print("NO")
0