結果

問題 No.179 塗り分け
ユーザー rpy3cpprpy3cpp
提出日時 2015-04-07 00:04:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,062 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-10 11:45:13
合計ジャッジ時間 2,950 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

def read_data():
    H, W = map(int, input().split())
    S = [input() for i in range(H)]
    return H, W, S

def solve(H, W, S):
    Smat = [[c == '#' for c in row] for row in S]
    if has_no_sharp(Smat):
        return False
    for h in range(H):
        for w in range(W):
            if h == w == 0:
                continue
            if can_be_painted(h, w, Smat, H, W):
                return True
    return False

def has_no_sharp(Smat):
    for row in Smat:
        if any(row):
            return True
    return False

def can_be_painted(h, w, Smat, H, W):
    Scopy = [row[:] for row in Smat]
    for x in range(H):
        for y in range(W):
            if Scopy[x][y]:
                if x+h >= H or y+w >= W or not Scopy[x+h][y+w]:
                    return False
                else:
                    Scopy[x+h][y+w] = False
    return True

H, W, S = read_data()
if solve(H, W, S):
    print("YES")
else:
    Sreverse = [list(reversed(row)) for row in S]
    if solve(H, W, Sreverse):
        print("YES")
    else:
        print("NO")
0