結果

問題 No.179 塗り分け
ユーザー fgshunfgshun
提出日時 2020-09-27 11:49:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,292 ms / 3,000 ms
コード長 1,025 bytes
コンパイル時間 905 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 83,404 KB
最終ジャッジ日時 2023-09-30 21:35:12
合計ジャッジ時間 25,006 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,576 KB
testcase_01 AC 88 ms
71,644 KB
testcase_02 AC 101 ms
77,252 KB
testcase_03 AC 88 ms
71,568 KB
testcase_04 AC 97 ms
76,136 KB
testcase_05 AC 232 ms
79,688 KB
testcase_06 AC 143 ms
78,128 KB
testcase_07 AC 89 ms
75,308 KB
testcase_08 AC 1,080 ms
83,348 KB
testcase_09 AC 1,040 ms
82,020 KB
testcase_10 AC 579 ms
81,336 KB
testcase_11 AC 521 ms
79,484 KB
testcase_12 AC 924 ms
80,960 KB
testcase_13 AC 110 ms
77,848 KB
testcase_14 AC 105 ms
77,064 KB
testcase_15 AC 85 ms
71,580 KB
testcase_16 AC 84 ms
71,424 KB
testcase_17 AC 86 ms
71,588 KB
testcase_18 AC 595 ms
81,436 KB
testcase_19 AC 590 ms
80,668 KB
testcase_20 AC 1,000 ms
81,420 KB
testcase_21 AC 1,129 ms
81,216 KB
testcase_22 AC 1,292 ms
81,216 KB
testcase_23 AC 592 ms
80,708 KB
testcase_24 AC 1,063 ms
81,856 KB
testcase_25 AC 612 ms
80,700 KB
testcase_26 AC 703 ms
80,748 KB
testcase_27 AC 1,083 ms
81,800 KB
testcase_28 AC 623 ms
80,880 KB
testcase_29 AC 1,047 ms
83,368 KB
testcase_30 AC 774 ms
81,096 KB
testcase_31 AC 1,042 ms
82,300 KB
testcase_32 AC 711 ms
81,856 KB
testcase_33 AC 1,032 ms
83,404 KB
testcase_34 AC 698 ms
80,836 KB
testcase_35 AC 1,091 ms
83,248 KB
testcase_36 AC 86 ms
71,668 KB
testcase_37 AC 87 ms
71,476 KB
testcase_38 AC 86 ms
71,312 KB
testcase_39 AC 86 ms
71,312 KB
testcase_40 AC 94 ms
76,040 KB
testcase_41 AC 87 ms
71,324 KB
testcase_42 AC 93 ms
75,944 KB
testcase_43 AC 161 ms
79,760 KB
testcase_44 AC 265 ms
79,148 KB
testcase_45 AC 123 ms
77,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import itertools
import copy

def _pred(move_x, move_y, H, W, s):
    if move_x == 0 and move_y == 0:
        return False
    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()])
    
    if all('b' not in s for s in S):
        return 'NO'

    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