結果

問題 No.179 塗り分け
ユーザー fgshunfgshun
提出日時 2020-09-27 10:47:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 946 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 12,752 KB
最終ジャッジ日時 2023-09-13 01:01:59
合計ジャッジ時間 7,002 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,424 KB
testcase_01 AC 19 ms
8,480 KB
testcase_02 AC 19 ms
8,456 KB
testcase_03 AC 19 ms
8,496 KB
testcase_04 AC 19 ms
8,348 KB
testcase_05 AC 740 ms
8,380 KB
testcase_06 AC 186 ms
8,460 KB
testcase_07 WA -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
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 sys
import itertools
import copy

def _pred(move_x, move_y, H, W, s):
    for x, y in itertools.product(range(H), range(W)):
        if s[x][y] == 'b':
            s[x][y] = 'R'
            x2 = x + move_x
            y2 = y + move_y
            if 0 <= x2 < H and 0 <= y2 < W and s[x2][y2] == 'b':
                s[x2][y2] = 'B'
            else:
                return False
    
    return True


def resolve(in_):
    H, W = map(int, next(in_).split())
    black = ord(b'#')
    white = ord(b' ')

    S = []
    for s in itertools.islice(in_, H):
        S.append(['b' if i == black else 'w' for i in s.rstrip()])

    max_x = W - 1
    max_y = H - 1
    ans = any(_pred(move_x, move_y, H, W, copy.deepcopy(S)) for move_x, move_y in itertools.product(range(-H + 1, H), range(-W + 1, W)))

    return 'YES' if ans else 'NO'
    

def main():
    ans = resolve(sys.stdin.buffer)

    print(ans)


if __name__ == '__main__':
    main()
0