結果

問題 No.179 塗り分け
ユーザー sue_charo
提出日時 2017-04-13 13:38:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 967 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,696 KB
最終ジャッジ日時 2024-10-03 03:39:14
合計ジャッジ時間 5,328 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 4 WA * 2 TLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

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