結果

問題 No.179 塗り分け
ユーザー sue_charosue_charo
提出日時 2017-04-13 13:38:33
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 967 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 13,016 KB
最終ジャッジ日時 2023-07-26 16:43:39
合計ジャッジ時間 5,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,448 KB
testcase_01 AC 19 ms
8,424 KB
testcase_02 AC 18 ms
8,500 KB
testcase_03 AC 18 ms
8,580 KB
testcase_04 AC 19 ms
8,516 KB
testcase_05 AC 19 ms
8,476 KB
testcase_06 AC 20 ms
8,664 KB
testcase_07 WA -
testcase_08 AC 21 ms
8,560 KB
testcase_09 WA -
testcase_10 AC 22 ms
8,732 KB
testcase_11 AC 21 ms
8,724 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 #

# coding: utf-8
from collections import deque

H, W = map(int, input().split())
# board[H][W]
board = [list(input()) for __ in range(H)]

sum_char = 0
index_board = []
for ind_h, row in enumerate(board):
    for ind_w, char in enumerate(row):
        if char == "#":
            sum_char += 1
            index_board.append((ind_h, ind_w))


def check(h, w):
    do_board = deque(index_board[:])
    while do_board:
        check_index = do_board.popleft()
        if (check_index[0] + h, check_index[1] + w) in do_board:
            do_board.remove((check_index[0] + h, check_index[1] + w))
        else:
            break
    else:
        return True

    return False

def solve():
    if sum_char % 2 == 1:
        return "NO"

    for h in range(H):
        for w in range(W):
            # print("h: {0}, w: {1}".format(h, w))
            if check(h, w):
                return "YES"
            else:
                continue

    return "NO"


print(solve())
0