結果

問題 No.179 塗り分け
ユーザー CsTarepandaCsTarepanda
提出日時 2019-04-21 21:28:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,821 ms / 3,000 ms
コード長 935 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-04-16 18:04:02
合計ジャッジ時間 12,016 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 31 ms
11,008 KB
testcase_02 AC 32 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 32 ms
10,880 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 33 ms
10,880 KB
testcase_08 AC 36 ms
11,008 KB
testcase_09 AC 35 ms
11,008 KB
testcase_10 AC 34 ms
11,136 KB
testcase_11 AC 34 ms
11,008 KB
testcase_12 AC 1,821 ms
11,008 KB
testcase_13 AC 32 ms
10,880 KB
testcase_14 AC 33 ms
10,880 KB
testcase_15 AC 32 ms
11,008 KB
testcase_16 AC 32 ms
10,880 KB
testcase_17 AC 32 ms
10,880 KB
testcase_18 AC 55 ms
11,008 KB
testcase_19 AC 54 ms
11,008 KB
testcase_20 AC 32 ms
10,880 KB
testcase_21 AC 31 ms
10,880 KB
testcase_22 AC 242 ms
11,008 KB
testcase_23 AC 35 ms
11,008 KB
testcase_24 AC 174 ms
11,136 KB
testcase_25 AC 40 ms
11,008 KB
testcase_26 AC 56 ms
11,136 KB
testcase_27 AC 661 ms
11,008 KB
testcase_28 AC 54 ms
11,008 KB
testcase_29 AC 1,007 ms
11,008 KB
testcase_30 AC 411 ms
11,136 KB
testcase_31 AC 1,218 ms
11,008 KB
testcase_32 AC 276 ms
11,008 KB
testcase_33 AC 1,237 ms
11,008 KB
testcase_34 AC 206 ms
11,008 KB
testcase_35 AC 1,430 ms
11,136 KB
testcase_36 AC 31 ms
10,880 KB
testcase_37 AC 31 ms
11,008 KB
testcase_38 AC 31 ms
10,880 KB
testcase_39 AC 32 ms
10,880 KB
testcase_40 AC 32 ms
11,008 KB
testcase_41 AC 31 ms
10,880 KB
testcase_42 AC 31 ms
11,008 KB
testcase_43 AC 54 ms
10,880 KB
testcase_44 AC 145 ms
11,008 KB
testcase_45 AC 35 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import copy
h, w = map(int, input().split())
start_x, start_y = None, None

field = [list(input()) for _ in range(h)]
black_n = "".join(map("".join, field)).count("#")

if black_n > 0 and black_n % 2:
    print("NO")
    exit()


def check(y, x):
    global start_x, start_y
    if field[y][x] != "#":
        return False
    if start_x is None:
        start_x = x
        start_y = y
    dx, dy = x - start_x, y - start_y
    m = copy.deepcopy(field)
    for red_y in range(h):
        for red_x in range(w):
            if m[red_y][red_x] == "#":
                m[red_y][red_x] = "@"
                nx = red_x + dx
                ny = red_y + dy
                if ny >= h or nx >= w or m[ny][nx] != "#":
                    return False
                m[ny][nx] = "@"
    return True



for i in range(h):
    for j in range(w):
        if check(i, j):
            print("YES")
            exit()
print("NO")
0