結果

問題 No.179 塗り分け
ユーザー hisaharuhisaharu
提出日時 2015-10-17 23:16:33
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-10 12:45:29
合計ジャッジ時間 2,218 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,816 KB
testcase_01 AC 10 ms
6,944 KB
testcase_02 AC 10 ms
6,940 KB
testcase_03 AC 10 ms
6,944 KB
testcase_04 AC 10 ms
6,948 KB
testcase_05 AC 19 ms
6,944 KB
testcase_06 AC 10 ms
6,940 KB
testcase_07 RE -
testcase_08 AC 10 ms
6,940 KB
testcase_09 AC 10 ms
6,944 KB
testcase_10 AC 13 ms
6,944 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 AC 219 ms
6,940 KB
testcase_13 AC 9 ms
6,944 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 9 ms
6,940 KB
testcase_16 AC 9 ms
6,944 KB
testcase_17 RE -
testcase_18 AC 11 ms
6,940 KB
testcase_19 AC 11 ms
6,944 KB
testcase_20 AC 80 ms
6,944 KB
testcase_21 AC 19 ms
6,940 KB
testcase_22 AC 31 ms
6,944 KB
testcase_23 AC 10 ms
6,940 KB
testcase_24 AC 15 ms
6,940 KB
testcase_25 AC 10 ms
6,944 KB
testcase_26 AC 11 ms
6,940 KB
testcase_27 AC 25 ms
6,940 KB
testcase_28 AC 12 ms
6,944 KB
testcase_29 AC 35 ms
6,940 KB
testcase_30 AC 22 ms
6,940 KB
testcase_31 AC 41 ms
6,940 KB
testcase_32 AC 17 ms
6,944 KB
testcase_33 AC 48 ms
6,944 KB
testcase_34 AC 16 ms
6,944 KB
testcase_35 AC 53 ms
6,940 KB
testcase_36 AC 10 ms
6,940 KB
testcase_37 AC 10 ms
6,944 KB
testcase_38 AC 10 ms
6,944 KB
testcase_39 AC 9 ms
6,944 KB
testcase_40 AC 10 ms
6,944 KB
testcase_41 AC 9 ms
6,944 KB
testcase_42 AC 10 ms
6,944 KB
testcase_43 AC 12 ms
6,944 KB
testcase_44 AC 13 ms
6,944 KB
testcase_45 AC 10 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def find_r(H, W, S):
    for y in range(H):
        for x in range(W):
            if S[y][x] == "#":
                return x, y

def check(B, rx, ry, bx, by):
#    print rx, ry, bx, by
    cy = by - ry
    cx = bx - rx
    for y in range(H):
        for x in range(W):
            if B[y][x] == "#":
                B[y][x] = "R"
                if y+cy not in range(H):
                    return False
                if x+cx not in range(W):
                    return False
                if B[y+cy][x+cx] == "#":
                    B[y+cy][x+cx] = "B"
                else:
                    return False
    return True

def print_s(S):
    print "\n".join(["".join(x) for x in S])

H, W = map(int, raw_input().split())
#print H, W
S = []
for i in range(H):
    S.append(list(raw_input()))

rx, ry = find_r(H, W, S)
S[ry][rx] = "R"
#print rx, ry, S

for by in range(H):
    for bx in range(W):
        if S[by][bx] != "#":
            continue
        B = map(list, S)
        B[by][bx] = "B"
        if check(B, rx, ry, bx, by):
            print "YES"
#            print_s(B)
            sys.exit(0)
print "NO"
0